用SimpleModal阻止onClose后,默认关闭控件不起作用
在基本的 SimpleModal 实现中,我使用 onClose
选项来检查脏表单状态并防止关闭:
..
function onModalClose() {
if (this.dirty &&
!confirm('You have unsaved changes, continue anyway?')) {
return;
}
this.dirty=false;
$.modal.close();
}
..
问题是如果用户取消关闭操作,对话框上的默认关闭控件将不再起作用。 $.modal.close()
仍然有效。
我确信我可以通过不使用默认按钮或执行诸如主动将我自己的关闭函数重新绑定到它的操作来解决此问题,但这看起来很奇怪,我想知道是否有一些我忽略的简单解决方案。
In a basic SimpleModal implementation, I use the onClose
option to check for a dirty form state and prevent closing:
..
function onModalClose() {
if (this.dirty &&
!confirm('You have unsaved changes, continue anyway?')) {
return;
}
this.dirty=false;
$.modal.close();
}
..
Problem is if the user cancels the close operation, the default Close control on the dialog no longer works. $.modal.close()
still works.
I am sure I can get around this by not using the default button, or doing something like actively re-binding my own close function to it, but this seems strange, and I wonder if there is some easy solution I'm overlooking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有点麻烦,但我通过以下代码取得了成功。 (注意:我定义了 onClose 函数,因此 this 指向模式对话框。)
It's a bit of a hack but I had success with the following code. (Note: I defined the onClose function, so this points to the modal dialog.)