gpt4 book ai didi

jquery - 用SimpleModal阻止onClose后,默认关闭控件不起作用

转载 作者:行者123 更新时间:2023-12-01 01:10:47 25 4
gpt4 key购买 nike

在基本的 SimpleModal 实现中,我使用 onClose 选项来检查脏表单状态并防止关闭:

.. 
function onModalClose() {
if (this.dirty &&
!confirm('You have unsaved changes, continue anyway?')) {
return;
}
this.dirty=false;
$.modal.close();
}
..

问题是,如果用户取消关闭操作,对话框上的默认关闭控件将不再起作用。 $.modal.close() 仍然有效。

我确信我可以通过不使用默认按钮或执行诸如主动重新绑定(bind)我自己的关闭函数之类的操作来解决此问题,但这看起来很奇怪,我想知道是否有一些简单的解决方案俯瞰。

最佳答案

这有点麻烦,但我通过以下代码取得了成功。 (注意:我定义了 onClose 函数,因此 this 指向模式对话框。)

 onClose: function () {
if (this.dirty &&
!confirm('You have unsaved changes, continue anyway?')) {
this.bindEvents();
this.occb = false;
return;
}
$.modal.close();
}

关于jquery - 用SimpleModal阻止onClose后,默认关闭控件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5669512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com