Written by Sean Behan on Sun Jun 17th 2012

It appears that the :disable_with option on the submit_tag form helper method does not behave as expected with remote forms. I'm not sure if this is a bug or not. But the fix is pretty straight forward, but perhaps a little difficult to trouble shoot. Using submit_tag inside a remote form

<%= submit_tag "Submit", :disable_with => "Submitting...." %>
Will not work.

You have to edit your public/javascripts/rails.js file around line #167

and change

document.on("ajax:after", "form", function(event, element) {


document.on("ajax:complete", "form", function(event, element) {

Then things will behave as expected. This assumes you are using Prototype (rather than jQuery).

Tagged with..
#ajax #disable_with #javascript #prototype #Rails #rails 3 #rails helpers #Front End Development #Ruby on Rails

Just finishing up brewing up some fresh ground comments...