Skip to content

Instantly share code, notes, and snippets.

@huacnlee
Last active November 13, 2018 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huacnlee/84d13ea64cc8ccb2d4b0 to your computer and use it in GitHub Desktop.
Save huacnlee/84d13ea64cc8ccb2d4b0 to your computer and use it in GitHub Desktop.
Custom confirmation dialog in Rails
// Override jquery_ujs data-confirm
// use bootbox.confirm instead of window.confirm
// https://gist.github.com/huacnlee/84d13ea64cc8ccb2d4b0
$.rails.allowAction = function(element) {
var message = element.attr('data-confirm');
if (!message) { return true; }
var opts = {
title: "确认提交",
message: message,
callback: function(ok) {
if (ok) {
element.removeAttr('data-confirm');
element.trigger('click.rails')
}
}
};
bootbox.confirm(opts);
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment