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?

7

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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