Permalink
Browse files

Update prototype-ujs for data-confirm

  • Loading branch information...
1 parent 3062bc7 commit 358968cd28b23c79a9311b5f88dce14fed686e97 @jeremy jeremy committed Feb 5, 2010
Showing with 12 additions and 5 deletions.
  1. +12 −5 railties/lib/generators/rails/app/templates/public/javascripts/rails.js
@@ -34,20 +34,27 @@ 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);
event.stop();
}
});
- $(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;

0 comments on commit 358968c

Please sign in to comment.