From 7affc55a2a2fc156ef2e20c6f4cdfb347604bd11 Mon Sep 17 00:00:00 2001 From: Steel Date: Tue, 22 Jun 2010 15:01:40 -0700 Subject: [PATCH] Add disable-with handlers for non-ajax forms --- src/rails.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/rails.js b/src/rails.js index 4e9a8aef..38cb6951 100644 --- a/src/rails.js +++ b/src/rails.js @@ -124,4 +124,18 @@ jQuery(function ($) { .val(input.data('enable-with')); }); }); + + /** + * disable-with handlers for non-ajax forms + */ + var non_ajax_disable_with_input_selector = 'input[data-disable-with]'; + var non_ajax_disable_with_form_selector = 'form:not([data-remote]):has(' + disable_with_input_selector + ')'; + + $(non_ajax_disable_with_form_selector).live('submit', function () { + $(this).find(disable_with_input_selector).each(function () { + var input = $(this); + input.attr('value', input.attr('data-disable-with')) + .attr('disabled', 'disabled'); + }); + }); });