Bram Jetten
Bram Jetten

Reputation: 282

Rails disable remote form submit

I have a form that I want to submit through AJAX most of the time. However, there's also multiple file fields in the form. Whenever a file is submitted I need to temporarily disable AJAX-functionality so that the file can be processed.

I tried removing the data-remote attribute, but of course that's not enough because jQuery already binds the AJAX function to the form. How do I unbind it?

Edit:

Oh wow, I'm so stupid. Rails does this by default. I hadn't even tried it yet. Sorry for polluting StackExchange.

Upvotes: 3

Views: 2635

Answers (3)

Bram Jetten
Bram Jetten

Reputation: 282

Oh wow, Rails does this by default. I hadn't even tried it yet. Sorry for polluting StackExchange.

Upvotes: 0

chuck w
chuck w

Reputation: 1761

Why don't you simply remove the data-remote attribute. If you are using jquery it would look something like this:

$("#element").removeAttr("data-remote");

Upvotes: 4

DeathHammer
DeathHammer

Reputation: 660

You can use :disable_with option like

<%= submit_tag 'Submit', :disable_with => 'Please wait..' %>

Upvotes: 3

Related Questions