I searched for this issues in * and have seen similar questions (but not exactly what I'm looking for), but the solution doesn't seem to work. I am just a newbie in jQuery and I need your help to be able to make this work. (cross fingers)
我在*中搜索了这个问题并且看到了类似的问题(但不完全是我正在寻找的),但解决方案似乎不起作用。我只是jQuery的新手,我需要你的帮助才能做到这一点。 (交叉手指)
So I have a webpage with a button (parentPage.html, for example). When the button is clicked (openItemPopup function is executed), it opens a modal dialog using jQuery UI. The content of the modal dialog "#contentWindow" is a different page (modalDialog.html, for example).
所以我有一个带有按钮的网页(例如,parentPage.html)。单击该按钮(执行openItemPopup函数)时,它将使用jQuery UI打开模式对话框。模态对话框“#contentWindow”的内容是一个不同的页面(例如modalDialog.html)。
function resetContent() {
$('#contentFrame').attr('src', '/images/ajax-loader.gif');
}
function closeContent() {
$('.ui-dialog-titlebar-close').click();
}
function openItemPopup(){
$('#contentWindow').dialog({width:980, modal: true,
close: function(ev, ui) { resetContent(); }
});
}
Inside modalDialog.html, when an anchor is clicked, it performs some logic and it needs to dynamically close the modal dialog. Someone told me to use this and this is already working:
在modalDialog.html中,当单击一个锚点时,它会执行一些逻辑,并且需要动态关闭模态对话框。有人告诉我使用它,这已经有效了:
// refresh parent page before closing
// doesn't work
location.reload(true);
// close the modal dialog
window.top.closeContent();
return false;
window.location='javascript:void();';
My problem is: I need to refresh the parentPage.html just before closing the modal dialog. You see above that I tried to use location.reload(true);, but it reloads the modal dialog and not the parentPage.html. I cannot post pictures but it says *"Invalid Web application session".*
我的问题是:我需要在关闭模式对话框之前刷新parentPage.html。您在上面看到我尝试使用location.reload(true);,但它重新加载模式对话框而不是parentPage.html。我无法发布图片,但它说*“无效的Web应用程序会话”。*
I also tried the window.top.location.reload(); and it seems to work. It reloads the parentPage.html and closes the modal dialog.
我也试过了window.top.location.reload();它似乎工作。它重新加载parentPage.html并关闭模式对话框。
// refresh parent page before closing
// seems working but has error
window.top.location.reload();
// close the modal dialog
window.top.closeContent();
return false;
window.location='javascript:void();';
However, it says "Invalid Web application session." -- just like how it was when using the location.reload(true);. I have no idea why this is happening and how to fix it. I am not even sure if window.top.location.reload is the correct method to do this.
但是,它说“无效的Web应用程序会话”。 - 就像使用location.reload(true);时一样。我不知道为什么会这样,以及如何解决它。我甚至不确定window.top.location.reload是否是正确的方法。
FYI: I am trying to refresh the parentPage.html to be able to get the data back from the modal dialog. Before, modalDialog.html used to function as a simple html page. Data such as list and fields are returned properly from modalDialog.html to parentPage.html. They wanted to convert it as a modal dialog to prevent A LOT of page refresh. Someone told me that it is possible to use AJAX but it is a lot of work. Besides, I'm no master of it. If you have a better suggestion, feel free to let me know!
仅供参考:我正在尝试刷新parentPage.html以便能够从模态对话框中获取数据。之前,modalDialog.html曾经用作简单的html页面。列表和字段等数据从modalDialog.html正确返回到parentPage.html。他们想将其转换为模态对话框,以防止大量页面刷新。有人告诉我,可以使用AJAX,但这是很多工作。此外,我不是主人。如果您有更好的建议,请随时告诉我!
I hope you can help me out on this. Thanks in advance!!!
我希望你能帮助我解决这个问题。提前致谢!!!
2 个解决方案
#1
5
In you dialog use the close: function (ev, ui) { window.location.reload() }
在你的对话框中使用close:function(ev,ui){window.location.reload()}
#2
2
Try this: in your parentPage.html add a new function:
试试这个:在你的parentPage.html中添加一个新函数:
function reloadContent() {
location.reload();
}
In your modalDialog.html call the function via:
在你的modalDialog.html中通过以下方式调用函数:
parent.reloadContent();
#1
5
In you dialog use the close: function (ev, ui) { window.location.reload() }
在你的对话框中使用close:function(ev,ui){window.location.reload()}
#2
2
Try this: in your parentPage.html add a new function:
试试这个:在你的parentPage.html中添加一个新函数:
function reloadContent() {
location.reload();
}
In your modalDialog.html call the function via:
在你的modalDialog.html中通过以下方式调用函数:
parent.reloadContent();