0

I have a strange situation whereby I have written my own code to open a modal popup window as shown below:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script type="text/javascript" language="javascript">
function showInPopup(popupURL)
{
var options = SP.UI.$create_DialogOptions(); 
     options.url = popupURL;
     options.width = 700;
     options.height = 540;
SP.UI.ModalDialog.showModalDialog(options);
}
</script>

For some reason this only works when I have the page (which includes this JS) checked out or me via the SP UI. When i do this the popup works for me and everyone else on the site. Once i check it in it no longer works...anyone ever seen this?

Regards,

S

9
  • Where do you add this script? It is not in an EditModePanel or smoething, right? May 13, 2013 at 11:00
  • The script was added in the Snippit webpart...
    – Stephen
    May 13, 2013 at 11:20
  • What is a snippit webpart? But ok. Have you checked the console for error messages? is SP.UI loaded? May 13, 2013 at 11:33
  • Its a webpart that allows you to add embeded code like JS etc. the SP.UI JS file is built into SP and is available in the _layout folder
    – Stephen
    May 13, 2013 at 11:54
  • I know it is built in to SharePoint, but is it loaded on your page? :) May 13, 2013 at 11:56

1 Answer 1

1

Finally worked it out, turns out the Masterpage that SP2013 created from my HTML page did NOT include the required JS files for modal popups to work. I had to edit the HTML file in SPD2013 and add the following code.

<!--MS:<SharePoint:ScriptLink ID="ScriptLink2" Name="SP.js" runat="server"     OnDemand="false" LoadAfterUI="true" Localizable="false">-->
    <!--ME:</SharePoint:ScriptLink>-->
    <!--MS:<SharePoint:ScriptLink ID="ScriptLink3" Name="SP.UI.Dialog.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false">-->
    <!--ME:</SharePoint:ScriptLink>-->
    <!--MS:<SharePoint:ScriptLink ID="ScriptLink4" Name="SP.Ribbon.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false">-->

I would have thought that this would have been added when the Masterpage was created/converted. One to watch out for.

Cheers for the input.

S

2
  • 1
    Haha, so I was right about the the SP.Ui not being loaded? :P May 14, 2013 at 10:35
  • Yes! ;-) I stupidly thought that the code to add the SP.UI JS files were added during the conversion process of HTML to Master page. Thanks for the help!
    – Stephen
    May 15, 2013 at 11:57

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.