SP.UI.ModalDialog does not work for published page

Regular Contributor

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;

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.



2 Replies

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?

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