Thursday, January 29, 2015

Opening and Closing Modal SP Dialog


Opening and closing SharePoint modal dialogs has been blogged to death already so here are a few resources for that:
The first thing that I wanted to point out is the SP.UI.ModalDialog.RefreshPage method. If dialog requires updating information on the parent page, which you may not have access to, you can use this method to force a page refresh if the dialog returns a success value. An example of this is when your dialog results in column values being updated on a SP list view.
      function myShowDialog() {
           var options = {
               url: LocationURL,
               dialogReturnValueCallback: feedbackReceived,
               title: "Add Follow Records"
           };
           SP.UI.ModalDialog.showModalDialog(options);
       }
         
       function feedbackReceived(dialogResult, returnValue) {
           if (dialogResult == SP.UI.DialogResult.OK) {
               location.href = location.href;
           } else {
               return false;
           }
SP.UI.ModalDialog.RefreshPage(dialogResult);
       }

No comments:

Post a Comment