Custom Javascript call after Content Search WebPart Display Template is rendered

%3CLINGO-SUB%20id%3D%22lingo-sub-68204%22%20slang%3D%22en-US%22%3ECustom%20Javascript%20call%20after%20Content%20Search%20WebPart%20Display%20Template%20is%20rendered%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-68204%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3CBR%20%2F%3E%3CBR%20%2F%3EI%20need%20to%20execute%20a%20custom%20JavaScript%20function%20once%20the%20display%20template%20of%20Content%20Search%20Webpart%20is%20rendered%20so%20I%20am%20calling%20that%20method%20inside%20%22AddPostRenderCallback%22%2C%20my%20custom%20JavaScript%20is%20executing%20a%20method%20(customCSWPContext.get_dataProvider().issueQuery()%3B)%20which%20reloads%20the%20webpart%20and%20hence%20it%20is%20getting%20stuck%20in%20infinite%20loop%20as%20custom%20function%20call%20inside%20%22AddPostRenderCallback%22%20will%20be%20executed%20again%20as%20webpart%20is%20reloaded%20by%20%22issueQuery%22%20method.%3CBR%20%2F%3EIs%20there%20any%20other%20way%20to%20execute%20a%20custom%20javascript%20after%20display%20template%20of%20CSWP%20is%20rendered%3F%20Any%20help%20would%20be%20highly%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ESumit%20Garg%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi All

I need to execute a custom JavaScript function once the display template of Content Search Webpart is rendered so I am calling that method inside "AddPostRenderCallback", my custom JavaScript is executing a method (customCSWPContext.get_dataProvider().issueQuery();) which reloads the webpart and hence it is getting stuck in infinite loop as custom function call inside "AddPostRenderCallback" will be executed again as webpart is reloaded by "issueQuery" method.
Is there any other way to execute a custom javascript after display template of CSWP is rendered? Any help would be highly appreciated.

 

Regards,

Sumit Garg

0 Replies