-
-
Save rubencp/f87b827707d9440d3941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require bootbox.min |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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
window.myCustomConfirmBox = function(message, callback) {
return bootbox.dialog({
message: message,
"class": 'class-confirm-box',
className: "my-modal",
buttons: {
success: {
label: "More than Sure, Thankyou!",
className: "btn-danger",
callback: function() {
return callback();
}
},
chickenout: {
label: "No, I'll chicken out!",
className: "btn-success pull-left"
}
}
});
};