SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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>
share|improve this question
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 '14 at 14:29

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

share|improve this answer
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 '14 at 17:37
Both tested and working! Erik, you saved me some overhead by providing the simplest sln .. ty – Colbs May 1 '14 at 17:48
That's great @Colbs. I'll let Andrey update his answer accordingly and he will have my vote :) – eirikb May 1 '14 at 17:54
Update done thanks eirikb) – Andrey Ungur May 1 '14 at 18:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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