> On Jan 13, 2016, at 12:44 AM, David Williams <li...@ruby-forum.com> wrote:
> 
>> 
>>    max_length = parseInt(counter.data('maximum-lenght'));
>> 
> 
> 
> It's giving me Nan when I wrap the parseInt method around the counter.

Check that your spelling of the attribute is correct, note the typo in the 
example. Also, if you want to be extra-careful (just had to deal with this 
yesterday) you can go all belt-and-suspenders on it:

    parseInt( 0 + counter.data('maximum-length') )

The leading 0 + won't change the value, but it will force JavaScript to cast an 
empty string to zero, so you don't get NaN (not a number), which may actually 
be true, depending on how the parser does with the data-attribute.

Walter

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/EAD0E938-1238-4A48-B626-108A0F801A3E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to