jQuery UI 对话框:单击外部时如何关闭对话框?
In docs I didn't see such information.
There are options to close dialog in such cases:
1) push Esc;
2) click on "OK" or "Close" buttons in the dialog.
But how to close dialog if click outside?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果对话框是模式对话框,则在创建对话框选项时将这 3 行代码粘贴到
open
函数中:If dialog is modal, then paste these 3 lines of code in the
open
function when you create your dialog options:面对同样的问题,我创建了一个小插件,可以在单击对话框外部时关闭对话框,无论是模式对话框还是非模式对话框。它支持同一页面上的一个或多个对话框。
有关我网站的更多信息: http:// www.coheractio.com/blog/looking-jquery-ui-dialog-widget-when-clicking-outside
该插件也在 github 上:https://github.com/coheractio/jQuery-UI-Dialog-ClickOutside
劳伦特
Facing the same problem, I have created a small plugin that enables to close a dialog when clicking outside of it whether it a modal or non-modal dialog. It supports one or multiple dialogs on the same page.
More information on my website here: http://www.coheractio.com/blog/closing-jquery-ui-dialog-widget-when-clicking-outside
The plugin is also on github: https://github.com/coheractio/jQuery-UI-Dialog-ClickOutside
Laurent
这是我的解决方案。
例如,我有
每个 div 作为一个对话框打开,具体取决于用户交互的内容。因此,为了能够关闭当前活动的,我这样做了。
This is my solution.
I have, for example
Each div gets opened as a dialog depending on what the user interacts with. So being able to close the currently active one, I do this.
以下是非模态对话框的另外 2 种解决方案:
如果对话框是非模态的 方法 1:
方法一: http://jsfiddle.net/jasonday/xpkFf/
非模态对话框 方法二:
http://jsfiddle.net/jasonday/eccKr/
Here are 2 other solutions for non-modal dialogs:
If dialog is non-modal Method 1:
method 1: http://jsfiddle.net/jasonday/xpkFf/
Non-Modal dialog Method 2:
http://jsfiddle.net/jasonday/eccKr/
我在 ryanjeffords.com:
I found solution on ryanjeffords.com: