Take advantage of Rails data attribute transformation to clean up your UJS
jquery-ujs gem, it’s almost encouraged!
Without writing any script yourself at all, you can have a form button that disables itself with a message while the form is submitted by simply constructing your button like so:
With Rails 4, however, using the
disable_with key directly has been deprecated - instead, Rails prefers that you place this attribute within a hash of
data - presumably to more closely resemble the HTML attributes - like so:
Interestingly though, I have noticed that any hash keys placed within the
data hash will be transformed into HTML data attributes - and most importantly, you can continue to use symbols, not strings, as the hash keys will automatically have underscores replaced with dashes, so: