This project is archived and is in readonly mode.
Rails3 disable_with remote form button immediately gets re-enabled
Reported by ph0rque | September 27th, 2010 @ 04:17 PM
When submitting a remote form with a "disable_with" option, the reasonable expectation is that the button will be re-enabled after the ajax response. Instead, the button is immediately re-enabled after the request is made but before the response is received. The problem is that the re-enabling code in rails.js (lines 167-174) is fired on ajax:after:
document.on("ajax:after", "form", function(event, element) {
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
inputs.each(function(input) {
input.value = input.readAttribute('data-original-value');
input.removeAttribute('data-original-value');
input.disabled = false;
});
});
If changed to be ajax:complete (line 167):
document.on("ajax:complete", "form", function(event, element) {
//original code here
}
The code works as expected: the button is disabled until the ajax response is received.
Comments and changes to this ticket
-
Ryan Bigg September 27th, 2010 @ 11:19 PM
- State changed from new to duplicate
- Importance changed from to Low
Duplicate of #5714.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>