0

I have an aspx page opened in a modal. On button click I need to close the current modal and open a new one or just open the new page in the same modal.

Any suggestions?

Below is my code:

function updateListItem(id,val) {

    var clientContext = args['context'];
    var oList = clientContext.get_web().get_lists().getByTitle('Weekly');

    this.oListItem = oList.getItemById(id);

    oListItem.set_item('SortOrder', val);

    oListItem.update();
    clientContext.executeQueryAsync(Function.createDelegate(this,this.succeed), Function.createDelegate(this,this.onQueryFailed));

}

function succeed() {

    window.frameElement.cancelPopUp(); 
    var options = SP.UI.$create_DialogOptions();
    options.width = 500;
    options.height = 250;
    options.url = dialogResult;
    SP.UI.ModalDialog.showModalDialog(options); 
}

But it gives me this error:

SCRIPT5011: Can't execute code from a freed script

1
1

The best way to open a modal dialog in SharePoint 2013 is to use the built-in JavaScript function called "OpenPopUpPage". This was introduced in SP2010 and is used widely throughout SP2013.

To change the page being loaded within the modal dialog, you can then use a simple "window.location.href" function.

EXAMPLES:

Opening a Modal Dialog

<a href="#" onclick="javascript:OpenPopUpPage('/Site/Lists/Weekly/Sorted.aspx', 'Weekly', 500, 250);">Open Dialog</a>

Changing What's in the Dialog

<a href="#" onclick="javascript:window.location.href('/Site/Lists/Weekly/Details.aspx');">View Details</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.