Skip to content

Instantly share code, notes, and snippets.

@TheAshwanik
Forked from cedricdekimpe/application.js
Created September 28, 2013 00:32
Show Gist options
  • Save TheAshwanik/6737044 to your computer and use it in GitHub Desktop.
Save TheAshwanik/6737044 to your computer and use it in GitHub Desktop.
//= require bootbox.min
$(document).ready(function() {
$.rails.allowAction = function(element) {
var message = element.data('confirm'),
answer = false, callback;
if (!message) { return true; }
if ($.rails.fire(element, 'confirm')) {
myCustomConfirmBox(message, function() {
callback = $.rails.fire(element,
'confirm:complete', [answer]);
if(callback) {
var oldAllowAction = $.rails.allowAction;
$.rails.allowAction = function() { return true; };
element.trigger('click');
$.rails.allowAction = oldAllowAction;
}
});
}
return false;
}
function myCustomConfirmBox(message, callback) {
bootbox.confirm(message, "Cancel", "Yes", function(confirmed) {
if(confirmed){
callback();
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment