1

I have a javascript file that I want to run after my display template has rendered. I have added it to my display template like so :

<script>
$includeLanguageScript(this.url, "~sitecollection/_catalogs/masterpage/Display Templates/Language Files/{Locale}/CustomStrings.js");
$includeScript(this.url, "~sitecollection/_catalogs/masterpage/Display Templates/Search/Customfeedbackinbox.js");
</script>
2

Display templates support OnPostRender event hanlder. You can invoke the JavaScript function using this

ctx.OnPostRender.push(ctx, function () {
    InvokeFunctions();
});

An excellent article Useful JavaScript to know when working with SharePoint Display Templates

  • the same functionality can be achieved using this AddPostRenderCallback(ctx, function () { // do something }); – jaku Jun 11 '15 at 8:00

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.