VocabReminder
Easily build a great vocabulary without studying! Now on the App Store!
Click here for more info about the app

Rails 3 disable_with Does Not Work with Ajax Remote Form_for

       

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) {

to

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

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

Tagged w/ #ajax #disable_with #javascript #prototype #rails #rails 3 #rails helpersfront end development #ruby on rails