Permalink
Browse files

Re-enable form fields if ajax:aborted:file handler returns false.

  • Loading branch information...
1 parent 9c8fc79 commit 8b147fb023f0d13deebea750e7e9827b6d3bc8ba @JangoSteve JangoSteve committed Aug 18, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/rails.js
View
@@ -366,8 +366,15 @@
if (remote) {
if (nonBlankFileInputs) {
+ // slight timeout so that the submit button gets properly serialized
+ // (make it easy for event handler to serialize form without disabled values)
setTimeout(function(){ rails.disableFormElements(form); }, 13);
- return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
+ var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
+
+ // re-enable form elements if event bindings return false (canceling normal form submission)
+ if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
+
+ return aborted;
}
// If browser does not support submit bubbling, then this live-binding will be called before direct

0 comments on commit 8b147fb

Please sign in to comment.