SharePoint 2013 JSLink OnPostRender

4.8k views Asked by At

I use JSLink to color a SharePoint 2013 task list.

This code is the entry point to call the 'HiglightRowOverride' function:

(function () {
var overrrideCtx = {};

overrrideCtx.Templates = {};
overrrideCtx.OnPostRender = [HiglightRowOverride];

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrrideCtx);})();

On the first load of the page with the list the JS is sometimes executed.

When i use F5 to refresh the page the JS is always executed.

When I click on the link to the list in the left sidebar again (list is already opened) the page refreshes but my JS is not executed. I debugged this with Chrome JS debugger.

I dunno why the JS is executed sometimes and sometimes not. Can you help me?

1

There are 1 answers

0
Thiago Silva On BEST ANSWER

Perhaps you're running into the "MDS" (Minimal Download Strategy) feature of SP2013.

Make sure you register your template overriding code as a module with RegisterModuleInit(), if you have MDS enabled in your site.

You can see this article for more details: http://blogs.msdn.com/b/sridhara/archive/2013/02/08/register-csr-override-on-mds-enabled-sharepoint-2013-site.aspx