0

I am building an display template. In the item template I have an onclick function on each item (picture). In this function I have some SharePoint Client Side code. The first row code is:

var clientContext = new SP.ClientContext();

In edit mode of my page it is working. When I publish the page I got this error:

Object doesn't support this action

I have googled and found these 2 solutions:

ExecuteOrDelayUntilScriptLoaded(updateProjectEC(), "sp.js");

or

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', updateProjectEC());

But how can I implement these solutions in my onclick event on each item. See the function "SetDetailInfo":

<div id="ItemAgenda">
<!--#_

var itemDate =  $getItemValue(ctx, "Created");
var itemBestuurderID =  $getItemValue(ctx, "Category");
itemBestuurderID.overrideValueRenderer($contentLineText);
var introText = $getItemValue(ctx, "IntroText");
introText.overrideValueRenderer($contentLineText);

var encodedId = $htmlEncode(ctx.ClientControl.get_nextUniqueId() + "_introTextId_");
var introTextId = encodedId + "introText";

_#-->
<img id="imgBestuurderFoto"  src="_#=itemDate=#_" width="200" height="200" onclick="SetDetailInfo('_#= itemBestuurderID =#_')" style="padding:0 !important;margin:0 !important;border:0 !important;" />
</div>
</body>
</html>
1

I found the answer my self. Add this registration in the masterpage:

<SharePoint:ScriptLink ID="ScriptLink21" Name="sp.js" runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false" />

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.