Ruby on Rails Tuesday, January 12, 2016

I'm unable to get the character counter to show an initial value.

When you type a something in, it says -1, -3, -4. It starts off at 0,
instead of the maximum amount allowed. I'd prefer it countdown from the
highest amount of characters allowed. 400, 399, 398, etc

$(document).ready(function() {
var counter, max_length, review_text;
review_text = $('#body');
counter = $('#counter');
max_length = counter.data('maximum-length');
review_text.keyup(function() {
counter.text(max_length - ($(this).val().length));
});
});

--
Posted via http://www.ruby-forum.com/.

--
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/49e727e98fa4947ce8d66dc0504a3924%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment