Tob*_*asz 6 javascript popup magnific-popup
我在我的解决方案中实现了Magnific Popup,我正在使用Bootbox来确认用户是否要关闭窗口而不保存更改等.
我连接我的自定义函数来关闭回调但它没有按预期工作.
$('#divThumbnails').magnificPopup({
delegate: 'a',
type: 'inline',
midClick: true,
callbacks: {
close: function () {
var confirm = bootbox.confirm('Are you sure?', function(result) {
});
if (confirm)
return true;
else
return false;
}
}
});
Run Code Online (Sandbox Code Playgroud)
这只是一个快速的样本,而不是生产代码.if-else语句存在,因为否则Bootbox对话框无法显示(通常不需要检查返回的值,因为它作为参数传递,在本例中称为result).
问题是,在我单击关闭按钮后,我的图像(这是弹出窗口的内容)消失了.我想有机会取消关闭操作并实现我需要在关闭弹出窗口之前触发的事件.
这是否可以通过Magnific Popup实现?
Dmi*_*nov 21
// this part overrides "close" method in MagnificPopup object
$.magnificPopup.instance.close = function () {
if (!confirm("Are you sure?")) {
return;
}
// "proto" variable holds MagnificPopup class prototype
// The above change that we did to instance is not applied to the prototype,
// which allows us to call parent method:
$.magnificPopup.proto.close.call(this);
};
Run Code Online (Sandbox Code Playgroud)
http://codepen.io/dimsemenov/pen/edCgo
| 归档时间: |
|
| 查看次数: |
8994 次 |
| 最近记录: |