Skip to content

Instantly share code, notes, and snippets.

@baxang
Created October 24, 2014 11:32
Show Gist options
  • Save baxang/7ff03eee02d83ea49222 to your computer and use it in GitHub Desktop.
Save baxang/7ff03eee02d83ea49222 to your computer and use it in GitHub Desktop.
Override Rails' jQuery-ujs default form disable behaviour: Keep the form disabled after a successful submission.
(function($, undefined) {
var $document = $(document);
$document.undelegate($.rails.formSubmitSelector, 'ajax:complete.rails');
$document.delegate($.rails.formSubmitSelector, 'ajax:error.rails', function(event) {
if (this == event.target) $.rails.enableFormElements($(this));
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment