Showing posts with label Parent window reload not working. Show all posts
Showing posts with label Parent window reload not working. Show all posts

Thursday, 17 July 2014

Parent window reload not working

Problem: After closing modal window, parent window is not reloading
Root Cause:  Code
Solution:
I was using "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK); " to close the modal window.
My Code is:
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK);
window.onbeforeunload = RefreshParent;
RefreshParent=function () {alert('hi');
if (window.opener != null && !window.opener.closed) {
window.opener.location.reload();
}
I am calling "RefreshParent" after SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK), which is not correct.
I changed my code like this..

window.onbeforeunload = RefreshParent;
RefreshParent=function () {alert('hi');
if (window.opener != null && !window.opener.closed) {
window.opener.location.reload();
}
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK);

Now Parent window is reloading.