从远程页面关闭jquery模式对话框 [英] Closing a jquery modal dialog from a remote page

查看:126
本文介绍了从远程页面关闭jquery模式对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在基于Grails的应用程序中使用jQuery-UI对话框小部件来加载远程页面(在这种情况下,是一个简单的文件上传表单)。远程页面是在我的项目的其他地方定义的,并且不知道它正在加载到对话框中。

I'm using the jQuery-UI dialog widget in a Grails-based application to load a remote page (in this case, a simple file upload form). The remote page is defined elsewhere in my project, and doesn't know it is being loaded in a dialog.

有没有什么办法通过链接关闭对话框远程页面?当我加载页面时,我是否需要以某种方式传递对话框的引用,还是有办法触发关闭事件,同时不知道对话框本身?

Is there any way to close the dialog via a link in the remote page? Would I have to somehow pass a reference to the dialog when I load the page, or is there a way to trigger the close event while remaining agnostic of the dialog itself?

推荐答案

试试这个HTML:

<a href="#" id="btnDone">CLOSE</a>

和这个JavaScript:

and this JavaScript:

$("#btnDone").click(function (e) {
e.preventDefault();
var dialogDiv = $("#btnDone").parents(".ui-dialog-content");
if (dialogDiv.length > 0) {
dialogDiv.dialog('close');
}
});

放入您的远程页面。它会查看它是否在对话框内,如果是,它会关闭它。如果没有,它什么都不会做。

in your remote page. It will look to see if it is inside a dialog and if so, it will close it. If not, it will do nothing.

这篇关于从远程页面关闭jquery模式对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆