简体   繁体   中英

How to refresh the parent page on closing the rad window

I have a opened a rad window using below java-script code given below. Now I want to refresh my parent page on closing the rad window. To achieve this i have linked a jquery method, OnSendInviteClose with onclose event. Now this code refreshes my parent page but some time it gives me error described as "can't execute code from a freed script". How to fix this issue or reload my parent page on close (any other way).

Thanks

var e_showaddresslist = function (sender, args) {
    var url = $page.url.create("Pages/CalendarInvites.aspx?parentScreen=sendInviteWnd");
    var win = $window.createPopup(url,
    {
        size: "750, 500", behaviors: Telerik.Web.UI.WindowBehaviors.Close | Telerik.Web.UI.WindowBehaviors.Maximize | Telerik.Web.UI.WindowBehaviors.Move | Telerik.Web.UI.WindowBehaviors.Reload | Telerik.Web.UI.WindowBehaviors.Modal, name: "sendInviteWnd", onclose: onSendInviteClose
    },
    function () {
        //$page.get_window().set_destroyOnClose(true);
    });
  }

function onSendInviteClose() {
        window.location.reload(true);
}

Note: All the code is place in the calendar.js file which has references in both parent and radwindow page.

Have a read of this What causes the error "Can't execute code from a freed script"

The try / catch solution may help in your case.

You can hook the OnClientColose to the RadWindow and refresh the page using document.location.reload().

function RefreshParentPage()//function in parent page
{
document.location.reload();
}

Thanks,
Saritha

Make sure the code is executed in the correct context, ie, in the main page and not in the CalendarInvites page.

Then, if this is ok, try adding a timeout like this:

function onSendInviteClose() {
 setTimeout(function() {
       window.location.reload(true);
}, 0); //you can also try increasing the timeout.
}

Usually, the cannot execute code from freed script means that the content page that is being disposed is still trying to run some code but it is orphaned (eg, other pieces of code it depends on are disposed, or its context is gone - the window object). Most often this would be the page in the iframe (ie, inside the RadWindow), but it may also be your main page.

Attached the 'onSendInviteClose' method on close event.

 var win = $window.createPopup(url,
    {
        size: "750, 500", behaviors: Telerik.Web.UI.WindowBehaviors.Close |Telerik.Web.UI.WindowBehaviors.Move,  onclose: onSendInviteClose
    }

Now create that method in the page from which the popup is opened. This function will automatically fired when popup window is closed.

function onSendInviteClose() {
    //get a reference to the current RadWindow
    var wndow = GetRadWindow();
    wndow .Close();
    // and as this method is present in parent page
    // we can refresh the page controls easily.
}

function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM