我想在关闭bpopup之前调用一个函数。我使用了以下代码:
$('#casepromptPopup').bPopup({
escClose: false,
closeClass: 'b-close',
modalClose: false,
onClose: function() {
confirm("Are you sure you wish to quit and grade your performance?");
我想在弹出关闭之前显示确认消息。但是在弹出窗口关闭后会触发onClose
方法。
答案 0 :(得分:0)
虽然我不喜欢插件修改,但似乎没有其他方法可以实现这一点。
修改bpopup.js:
1。查看function close()
并添加if(o.confirmClose()){
:
function close() {
if(o.confirmClose()){
// rest of the original function
}
}
2。查找$.fn.bPopup.defaults = {
(位于底部)并添加:
confirmClose: function(){return true;}
现在您可以在bpopup选项中添加确认信息:
$('#casepromptPopup').bPopup({
escClose : false,
closeClass : 'b-close',
confirmClose : function(){
return confirm("Are you sure you wish to quit and grade your performance?");
}
});
<强> JSFiddle 强>