aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/generators/rails/app/templates/public/javascripts/rails.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/railties/lib/generators/rails/app/templates/public/javascripts/rails.js b/railties/lib/generators/rails/app/templates/public/javascripts/rails.js
index 2a0a05d25f..8e2e0d259d 100644
--- a/railties/lib/generators/rails/app/templates/public/javascripts/rails.js
+++ b/railties/lib/generators/rails/app/templates/public/javascripts/rails.js
@@ -34,6 +34,12 @@ document.observe("dom:loaded", function() {
}
$(document.body).observe("click", function(event) {
+ var message = event.element().readAttribute('data-confirm');
+ if (message && !confirm(message)) {
+ event.stop();
+ return false;
+ }
+
var element = event.findElement("a[data-remote=true]");
if (element) {
handleRemote(element);
@@ -41,13 +47,14 @@ document.observe("dom:loaded", function() {
}
});
- $(document.body).observe("ajax:before", function(event) {
- var message = event.element().readAttribute('data-confirm');
- if (message && !confirm(message)) event.stop();
- });
-
// TODO: I don't think submit bubbles in IE
$(document.body).observe("submit", function(event) {
+ var message = event.element().readAttribute('data-confirm');
+ if (message && !confirm(message)) {
+ event.stop();
+ return false;
+ }
+
var inputs = event.element().select("input[type=submit][data-disable-with]");
inputs.each(function(input) {
input.disabled = true;