aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-02-04 17:46:29 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2010-02-04 17:46:29 -0800
commit358968cd28b23c79a9311b5f88dce14fed686e97 (patch)
treef69f29c37bcd7c5f30a1f242f8b2d537c5367da9 /railties
parent3062bc70eff68397a00fc652e8eee4ae8089e0a2 (diff)
downloadrails-358968cd28b23c79a9311b5f88dce14fed686e97.tar.gz
rails-358968cd28b23c79a9311b5f88dce14fed686e97.tar.bz2
rails-358968cd28b23c79a9311b5f88dce14fed686e97.zip
Update prototype-ujs for data-confirm
Diffstat (limited to 'railties')
-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;