Skip to content

Instantly share code, notes, and snippets.

@thehungrycoder
Created November 14, 2012 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thehungrycoder/4072503 to your computer and use it in GitHub Desktop.
Save thehungrycoder/4072503 to your computer and use it in GitHub Desktop.
myCustomConfirmBox = function(message, callback) {
var options;
options = [
{
'label': 'Yes, Definitely',
'class': 'btn-danger',
'callback': function() {
if (typeof callback === 'function') {
return callback();
}
}
}, {
'label': 'Opss! No',
'class': 'btn-success'
}
];
return bootbox.dialog(message, options);
};
$.rails.allowAction = function(element) {
var answer, callback, message;
message = element.data("confirm");
if (!message) {
return true;
}
answer = false;
callback = void 0;
if ($.rails.fire(element, "confirm")) {
myCustomConfirmBox(message, function() {
var oldAllowAction;
callback = $.rails.fire(element, "confirm:complete", [answer]);
if (callback) {
oldAllowAction = $.rails.allowAction;
$.rails.allowAction = function() {
return true;
};
element.trigger("click");
return $.rails.allowAction = oldAllowAction;
}
});
}
return false;
};
window.myCustomConfirmBox = (message, callback) ->
options = [
{
'label': 'Yes, Definitely'
'class': 'btn-danger'
'callback': ->
if typeof callback == 'function'
callback()
}
{
'label': 'Opss! No'
'class': 'btn-success'
}
]
bootbox.dialog message, options
$.rails.allowAction = (element) ->
message = element.data("confirm")
return true unless message
answer = false
callback = undefined
if $.rails.fire(element, "confirm")
myCustomConfirmBox message, ->
callback = $.rails.fire(element, "confirm:complete", [answer])
if callback
oldAllowAction = $.rails.allowAction
$.rails.allowAction = ->
true
element.trigger "click"
$.rails.allowAction = oldAllowAction
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment