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");


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");
var introText = $getItemValue(ctx, "IntroText");

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;" />

1 Answer 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 and acknowledge you have read our privacy policy.

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