Skip to content

Commit

Permalink
Narrow scope of disable-with selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
qhoxie committed Feb 14, 2010
1 parent 8c866a6 commit 7dee0af
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rails.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ jQuery(function ($) {
/**
* disable-with handlers
*/
$('form[data-remote]').live('ajax:before', function () {
$(this).find('input[data-disable-with]').each(function () {
var disable_with_input_selector = 'input[data-disable-with]';
var disable_with_form_selector = 'form[data-remote]:has(' + disable_with_input_selector + ')';

$(disable_with_form_selector).live('ajax:before', function () {
$(this).find(disable_with_input_selector).each(function () {
var input = $(this);
input.data('enable-with', input.val())
.attr('value', input.attr('data-disable-with'))
.attr('disabled', 'disabled');
});
});

$('form[data-remote]').live('ajax:after', function () {
$(this).find('input[data-disable-with]').each(function () {
$(disable_with_form_selector).live('ajax:after', function () {
$(this).find(disable_with_input_selector).each(function () {
var input = $(this);
input.removeAttr('disabled')
.val(input.data('enable-with'));
Expand Down

0 comments on commit 7dee0af

Please sign in to comment.