This exercise was a bit tricky. Figured I\'d post my solution to see if anyone did it differently or if there\'s anyone who knows a better way.
I\'m not sure on best pra
Here's my coffeescript version based on Adriano's solution. This ignores whitespace, doesn't involve adding empty divs into the view, and also adds an error class once you get to minus numbers.
updateCountdown = ->
text = jQuery('#micropost_content').val()
text = text.replace(/\s/g, '');
remaining = 140 - text.length
jQuery('.countdown').text remaining + ' characters remaining'
jQuery('.countdown').addClass 'alert alert-error' if remaining < 0
jQuery('.countdown').removeClass 'alert alert-error' if remaining > 0
jQuery(document).ready ->
jQuery('#new_micropost').append '140 characters remaining'
jQuery('#micropost_content').change updateCountdown
jQuery('#micropost_content').keyup updateCountdown
return