SP.UI.ModalDialog from Web Part site not working but in AddIn site it works


  • Hello,

    I created a SharePoint Online Hosted AddIn in which I will open a modal dialog via

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

    This works well in the AddIn-site default.aspx but now I created a web part site in the AddIn but with the same code nothing happens when executing the command above also no error is shown on Debuggers (Internet Explorer, Firebug with Firefox).

    Do I have to change something in the code when executing a modal dialog from a web part site regarding default.aspx site of the AddIn?

    In the web part I added the following script references:

    <script type="text/javascript" src="/_layouts/15/init.js"></script>
    <script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <script type="text/javascript" src="../Scripts/App.js"></script>

    I hope anyone has an idea...

    Thank you very much in advance!

    Kind regards,

    • Edited by RoMeH Sunday, October 2, 2016 9:29 AM
    Sunday, October 2, 2016 9:27 AM


  • If I add the following reference to sp.js a second time via Script-Link-tag then the modal dialog is shown. 

    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <SharePoint:ScriptLink name="sp.js" runat="server" OnDemand="true" LoadAfterUI="true" Localizable="false" />
    Kind regards,

    • Marked as answer by RoMeH Sunday, October 2, 2016 8:21 PM
    Sunday, October 2, 2016 8:21 PM