5

I have created a dialog with the following code:

function Dialog() {
   var options = {
    url: 'http://mysite/mypage.aspx',
    title: 'My Title',
    allowMaximize: false,
    showClose: true,
    width: 400,
    height: 350,
    dialogReturnValueCallback: RefreshOnDialogClose

  };    
   SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}

this dialog works good and after i click save it refreshes the page, but if i click close or cancel it refreshes the page again.

So I want only when the save button is clicked to refresh page, not when close or cancel is pressed.

Thanks

  • are you using a function at RefreshOnDialogClose should you post it ? – Mohamed El-Qassas MVP Dec 17 '16 at 12:39
  • No I just wrote it there I don't have any function with that name, perhaps it is in any JS script – Nderon Hyseni Dec 17 '16 at 12:50
11

You can do the following:

 var options = {
    url: 'https://sp2013dev/sites/dev/Shared%20Documents/Forms/EditForm.aspx?ID=9',
    title: 'My Title',
    allowMaximize: false,
    showClose: true,
    width: 400,
    height: 350,
    dialogReturnValueCallback: function(result){
        if (result == SP.UI.DialogResult.OK) {
            window.location.reload();
        }
        if (result == SP.UI.DialogResult.cancel) {
            //do nothing, modal was closed
        }
    }

  };    
   SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);  

Be default RefreshOnDialogClose always reloads.

5

Try to remove RefreshOnDialogClose and set dialogReturnValueCallback: to a function, and check in this function the dialogResult to refresh on OK only as the following:

 dialogReturnValueCallback: function (dialogResult) {
      if (dialogResult == SP.UI.DialogResult.OK) {
           SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
      }

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.