diff options
author | Erik St. Martin <alakriti@gmail.com> | 2010-01-27 21:35:58 -0500 |
---|---|---|
committer | Erik St. Martin <alakriti@gmail.com> | 2010-01-27 21:35:58 -0500 |
commit | eff999d67933a4e7e349875b51fa6a6469b61d93 (patch) | |
tree | 46bd9e68fef1f34f81d0edad6af37d037abd8e01 /railties/lib/generators | |
parent | a0232d864177d14476bff73ac274a3ed820153f3 (diff) | |
download | rails-eff999d67933a4e7e349875b51fa6a6469b61d93.tar.gz rails-eff999d67933a4e7e349875b51fa6a6469b61d93.tar.bz2 rails-eff999d67933a4e7e349875b51fa6a6469b61d93.zip |
initial prototype of jQuery driver complete
Diffstat (limited to 'railties/lib/generators')
-rw-r--r-- | railties/lib/generators/rails/app/templates/public/javascripts/jquery.driver.js | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/railties/lib/generators/rails/app/templates/public/javascripts/jquery.driver.js b/railties/lib/generators/rails/app/templates/public/javascripts/jquery.driver.js index 52e35ec8bc..887da514e2 100644 --- a/railties/lib/generators/rails/app/templates/public/javascripts/jquery.driver.js +++ b/railties/lib/generators/rails/app/templates/public/javascripts/jquery.driver.js @@ -1,6 +1,3 @@ -// TODO: confirm -// TODO: popup -// TODO: disable_with jQuery(function ($) { var rails = { update: function (selector, content, position) { @@ -76,6 +73,21 @@ jQuery(function ($) { } }, complete: function (xhr) { + // enable disabled_with buttons + if (el[0].tagName.toUpperCase() == 'FORM') { + el.children('input[type="button"][data-enable-with],input[type="submit"][data-enable-with]').each(function(i, button){ + button = $(button); + button.attr('value', button.attr('data-enable-with')); + button.removeAttr('data-enable-with'); + button.removeAttr('disabled'); + + }); + } else { + el.attr('value', el.attr('data-enable-with')); + el.removeAttr('data-enable-with'); + el.removeAttr('disabled'); + } + el.trigger('rails:complete', xhr); el.trigger('rails:loaded', xhr); }, @@ -121,7 +133,7 @@ jQuery(function ($) { * confirm * make sure this event is first! */ - $('a[data-confirm],input[data-confirm]').live('click', function(e){ + $('a[data-confirm],input[type="submit"][data-confirm],input[type="button"][data-confirm]').live('click', function(e){ var el = $(this); if(!confirm(el.attr('data-confirm'))){ @@ -147,6 +159,17 @@ jQuery(function ($) { }); /** + * disable_with + */ + $('input[type="button"][data-disable-with],input[type="submit"][data-disable-with]').live('click', function(e){ + var el = $(this); + + el.attr('data-enable-with', el.attr('value')); + el.attr('disabled', 'disabled'); + el.attr('value', el.attr('data-disable-with')); + }); + + /** * remote_form_tag, and remote_form_for */ $('form[data-remote="true"]').live('submit', rails.remote); @@ -159,7 +182,7 @@ jQuery(function ($) { /* * popup */ - $('a[data-popup],input[data-popup]').live('click', function(e){ + $('a[data-popup],input[type="button"][data-popup]').live('click', function(e){ var el = $(this), url = el.attr('data-url') || el.attr('href'); |