Last active
November 13, 2018 11:37
-
-
Save huacnlee/84d13ea64cc8ccb2d4b0 to your computer and use it in GitHub Desktop.
Custom confirmation dialog in Rails
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
// 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