Forum Discussion

null null's avatar
null null
Iron Contributor
Jun 29, 2017

SP.UI.ModalDialog does not work for published page

Hi, I was trying to write some js code for modal window using 

 

function OpenDialog(url) {
      var options = SP.UI.$create_DialogOptions();
      options.url = url;
      options.width = 769;
      options.height = 500;
      SP.UI.ModalDialog.showModalDialog(options);
   }

However, the page works fine in edit mode but when i publish the code does not seem to work.

Could you please let me know, how get around it.

 

Thanks

2 Replies

  • Shawn Xiong's avatar
    Shawn Xiong
    Brass Contributor

    use SP.SOD.loadMultiple to ensure 'sp.ui.dialog.js' is loaded before using modal dialog.

  • If I recall, when you're in edit mode, additional scripts are loaded into the page that may not be present in presentation mode. Can you confirm SP.js and SP.UI.Dialog.js are loading on the page when you're out of edit mode?

Resources