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 :

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

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

ctx.OnPostRender.push(ctx, function () {

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

| improve this answer | |
  • 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.