From f00b74d235f8dacb272faeae29f4758723743f49 Mon Sep 17 00:00:00 2001 From: Quin Hoxie Date: Sat, 13 Feb 2010 21:48:45 -0800 Subject: [PATCH 1/4] Allow arbitrary nesting of disable-with --- src/rails.js | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rails.js b/src/rails.js index d03c462..93ce807 100644 --- a/src/rails.js +++ b/src/rails.js @@ -105,7 +105,7 @@ jQuery(function ($) { * disable_with handlers */ $('form[data-remote]').live('ajax:before', function () { - $(this).children('input[data-disable-with]').each(function () { + $(this).find('input[data-disable-with]').each(function () { var input = $(this); input.data('enable_with', input.val()) .attr('value', input.attr('data-disable-with')) @@ -114,7 +114,7 @@ jQuery(function ($) { }); $('form[data-remote]').live('ajax:after', function () { - $(this).children('input[data-disable-with]').each(function () { + $(this).find('input[data-disable-with]').each(function () { var input = $(this); input.removeAttr('disabled') .val(input.data('enable_with')); -- 1.6.3.3 From 9e39368cd3884568051d03911ac0f64e885ff9f3 Mon Sep 17 00:00:00 2001 From: Quin Hoxie Date: Sat, 13 Feb 2010 21:50:53 -0800 Subject: [PATCH 2/4] Use $ alias consistently --- src/rails.js | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/rails.js b/src/rails.js index 93ce807..c3e2832 100644 --- a/src/rails.js +++ b/src/rails.js @@ -12,7 +12,7 @@ jQuery(function ($) { * own events and placing ourselves at the end of the chain. */ triggerAndReturn: function (name, data) { - var event = new jQuery.Event(name); + var event = new $.Event(name); this.trigger(event, data); return event.result !== false; -- 1.6.3.3 From 8c866a61bd34b2292ecaf04a3af0e4ae8bdc3e2b Mon Sep 17 00:00:00 2001 From: Quin Hoxie Date: Sat, 13 Feb 2010 21:57:58 -0800 Subject: [PATCH 3/4] Small naming consistency changes --- src/rails.js | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rails.js b/src/rails.js index c3e2832..426a6ba 100644 --- a/src/rails.js +++ b/src/rails.js @@ -102,12 +102,12 @@ jQuery(function ($) { }); /** - * disable_with handlers + * disable-with handlers */ $('form[data-remote]').live('ajax:before', function () { $(this).find('input[data-disable-with]').each(function () { var input = $(this); - input.data('enable_with', input.val()) + input.data('enable-with', input.val()) .attr('value', input.attr('data-disable-with')) .attr('disabled', 'disabled'); }); @@ -117,7 +117,7 @@ jQuery(function ($) { $(this).find('input[data-disable-with]').each(function () { var input = $(this); input.removeAttr('disabled') - .val(input.data('enable_with')); + .val(input.data('enable-with')); }); }); }); -- 1.6.3.3 From 7dee0af93def99290d6f01819ea299c0e8fe5c9c Mon Sep 17 00:00:00 2001 From: Quin Hoxie Date: Sat, 13 Feb 2010 23:39:55 -0800 Subject: [PATCH 4/4] Narrow scope of disable-with selectors --- src/rails.js | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rails.js b/src/rails.js index 426a6ba..f2a40a2 100644 --- a/src/rails.js +++ b/src/rails.js @@ -104,8 +104,11 @@ 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')) @@ -113,8 +116,8 @@ jQuery(function ($) { }); }); - $('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')); -- 1.6.3.3