From e1f6296c4488e7d144756f1095da2731462aee84 Mon Sep 17 00:00:00 2001 From: Robert Lail Date: Thu, 15 Apr 2010 21:21:23 -0500 Subject: [PATCH 1/2] the submit event doesn't bubble in IE; added work-around to rails.js --- .../app/templates/public/javascripts/rails.js | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js b/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js index c5fa02a..6821ff9 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +++ b/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js @@ -80,8 +80,7 @@ document.observe("dom:loaded", function() { } }); - // TODO: I don't think submit bubbles in IE - $(document.body).observe("submit", function(event) { + function submit_handler(event) { var element = event.findElement(), message = element.readAttribute('data-confirm'); if (message && !confirm(message)) { @@ -102,6 +101,22 @@ document.observe("dom:loaded", function() { event.stop(); } }); + + // The submit event does not bubble in IE + // We need to listen to form elements themselves + // We'll do that when any part of a form gets focus + if(Prototype.Browser.IE) { + $(document.body).observe("focusin", function(event) { + var form = event.findElement("form"); + if(form && !form.submit_bubbles_on_ie) { + form.submit_bubbles_on_ie = true; + form.observe("submit", submit_handler); + } + }); + } else { + $(document.body).observe("submit", submit_handler); + } + $(document.body).observe("ajax:after", function(event) { var element = event.findElement(); -- 1.6.6 From 4fd66d26d357ad25d5d1ec1f0f5943d47b78c475 Mon Sep 17 00:00:00 2001 From: Robert Lail Date: Sat, 17 Apr 2010 09:03:25 -0500 Subject: [PATCH 2/2] fixed syntax error in last commit --- .../app/templates/public/javascripts/rails.js | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js b/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js index 6821ff9..f46e971 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +++ b/railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js @@ -100,7 +100,7 @@ document.observe("dom:loaded", function() { handleRemote(element); event.stop(); } - }); + } // The submit event does not bubble in IE // We need to listen to form elements themselves -- 1.6.6