4

I got "unable to get property 'showmodaldialog' of undefined or null reference" error when I try to open the list displayform in SharePoint 2013 modal dialog.

This is my script code:

<script type="text/javascript">
        function openDialog( pUrl ) {  
         SP.UI.ModalDialog.showModalDialog(   
         {  
          url: pUrl,
         width: 650,  
         height:600,  
         title: "MyTitle"
          }  
         );  
    }  
</script>

Calling:

<a href="javascript:openDialog('../../News/Lists/Posts/Post.aspx?ID={@ows_ID}')"><xsl:value-of select="@ows_LinkTitle"/></a>

Could anyone help me to resolve this issue?

1 Answer 1

9

This is happening because SP.UI.Dialog.js file is not loaded. Modify your code as below

<script type="text/javascript">
    function openDialog( pUrl ) {  
        var options = {
            url: pUrl,
            width: 650,  
            height:600,  
            title: "MyTitle"
        };
        SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    }  
</script>
1
  • Would you happen to know why just SP.UI.ModalDialog.showModalDialog(options); worked on my computer, but not to the rest of the company?
    – Jaitsujin
    Oct 3, 2022 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.