> On Jan 13, 2016, at 7:48 AM, Walter Lee Davis <waltd@wdstudio.com> wrote:
>
>
>> On Jan 13, 2016, at 12:44 AM, David Williams <lists@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') )
Sorry, left out one more bit here:
parseInt( 0 + counter.data('maximum-length'), 10 )
The second argument to parseInt forces it to consider the input to be an n-base number, so it won't misinterpret a string 'number' as belonging to a different encoding scheme.
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+unsubscribe@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/1F673D88-EDE5-4AA4-826F-62A73D6D49DF%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment