I have a link when clicked, shows the New Item dialog. When the user clicks 'Save', the list item is added. Is there a way to attach the dialog's onClose event to another piece of code? Or can I somehow listen for when this dialog closes and refresh the page (so the new item shows in my custom list view)?

Here is the link that opens the dialog:

<a href=\"javascript:OpenPopUpPage('/site/Lists/ListName/NewForm.aspx?IsDlg=1'>New Item</a>
  • To simply refresh the parent page after the modal dialog closes, add "RefreshPage" to the end of your call. Ex - javascript:OpenPopUpPage('/site/index.aspx', RefreshPage);
    – Omegacron
    Jul 11, 2014 at 14:29

1 Answer 1


You can use SharePoint SP.UI.ModalDialog.OpenPopUpPage(url, callback, width, height) Method and set callback function that runs when the modal dialog is closed.


  1. url Type: String The URL of the page to be shown in the modal dialog.
  2. callback Type: function pointer The callback function that runs when the modal dialog is closed.
  3. width Type: int The width of the modal dialog.
  4. height Type: int The height of the modal dialog.

Link to MSDN

  • 2
    Just a note, OP could probably just keep using the same function and the second argument for the redirect. e.g., OpenPopUpPage('...',function(saved){window.location='...'})
    – eirikb
    May 1, 2014 at 17:37
  • 1
    Both tested and working! Erik, you saved me some overhead by providing the simplest sln .. ty May 1, 2014 at 17:48
  • That's great @Colbs. I'll let Andrey update his answer accordingly and he will have my vote :)
    – eirikb
    May 1, 2014 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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