1

We are using John Liu's configure custom actions page to add some custom javascript to our site.

We are using the Oslo master page which comes with the following five scriptlinks.

    <!--SPM:<SharePoint:ScriptLink language="javascript" name="core.js" OnDemand="true" runat="server" Localizable="false"/>-->
    <!--SPM:<SharePoint:ScriptLink language="javascript" name="menu.js" OnDemand="true" runat="server" Localizable="false"/>-->
    <!--SPM:<SharePoint:ScriptLink language="javascript" name="callout.js" OnDemand="true" runat="server" Localizable="false"/>-->
    <!--SPM:<SharePoint:ScriptLink language="javascript" name="sharing.js" OnDemand="true" runat="server" Localizable="false"/>-->
    <!--SPM:<SharePoint:ScriptLink language="javascript" name="suitelinks.js" OnDemand="true" runat="server" Localizable="false"/>-->

Several of our functions rely on _spPageContextInfo and others SP.ClientContext. In both cases they tend to fail because sp.js isn't loading.

At first I tried to add it to the master page just like the original 5, but it just caused an error and no page rendered at all.

I also tried adding sp.js using the custom actions page, but I would get cannot read property majorVersion of null because things weren't loading in the right order.

Finally I had to just add something like this to every code file:

RegisterSod('sp.runtime.js', '/_layouts/15/sp.runtime.js');
RegisterSod('sp.js', '/_layouts/15/sp.js');
RegisterSod('sp.ui.dialog.js', '/_layouts/15/sp.ui.dialog.js')
RegisterSod('sp.workflowservices.js', '/_layouts/15/sp.workflowservices.js')

SP.SOD.loadMultiple(
    ['sp.runtime.js',
     'sp.js',
     'sp.ui.dialog.js',
     'sp.workflowservices.js'
    ],function(){....

I've got other files that are needed, like: reputation.js, sp.taxonomy.js, clientemplates.js, clientforms.js, clientpeoplepicker.js, autofill.js, and clienttemplates.js.

So here are my questions:

  1. Why can't I add them to Oslo master page the same way I add them to Seattle?
  2. Why aren't all the built in bits already registered with SOD?
  3. Why isn't core loading sp and such?
  4. Is there an easier way to do this?

Your Answer

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

Browse other questions tagged or ask your own question.