Tuesday, August 20, 2013

SharePoint 2013 migration issue with the SP.UI.ModalDialog error in javascript of CEWP

When there are javascript added to the Content Editor Web Part in SharePoint 2010, to open the dialog the code below is how you would do it but it breaks when you upgrade to 2013.

This works best if you add the new Script Webpart to the page and copy and paste all the scripts from the CEWP and leave the html as is.  

function openFormDialog(formtitle, formurl)
{
 var options = {
             url: formurl,
             tite: formtitle
         };

         SP.UI.ModalDialog.showModalDialog(options);
}

breaks in 2013

to fix the issue change the call to

function openFormDialog(formtitle, formurl)
{
 var options = {
             url: formurl + "?IsDlg=1",
             tite: formtitle
         };

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

No comments:

Post a Comment