Skip to content

Commit

Permalink
Made confirm:complete event fire always, passing in result of confirm…
Browse files Browse the repository at this point in the history
… dialog as data.
  • Loading branch information
JangoSteve committed May 8, 2011
1 parent 54dc9ce commit 50c06dc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/rails.js
Expand Up @@ -179,8 +179,15 @@
Attaching a handler to the element's `confirm` event that returns false cancels the confirm dialog.
*/
allowAction: function(element) {
var message = element.data('confirm');
return !message || (rails.fire(element, 'confirm') && confirm(message) && rails.fire(element, 'confirmed'));
var message = element.data('confirm'),
answer = false, callback;
if (!message) { return true; }

if (rails.fire(element, 'confirm')) {
answer = confirm(message);
callback = rails.fire(element, 'confirm:complete', [answer]);
}
return answer && callback;
},

// Helper function which checks for blank inputs in a form that match the specified CSS selector
Expand Down

0 comments on commit 50c06dc

Please sign in to comment.