I am not able to get any of my JSLink working. What am I doing wrong

236 Views Asked by At

We have SharePoint 2013 on Prem and I am trying to do some customizations using JS Link. Even the most simple exercises are not working. I don't understand what I'm doing wrong.

New page - List added and jS Link = ~site/SiteAssets/js-test/OverRideCustomHeader.js

(function () {
var overrideContext = {};
overrideContext.Templates = {};
overrideContext.Templates.Header = overrideCustomHeader;
overrideContext.Templates.Footer = overrideCustomFooter;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
})();

function overrideCustomHeader() {
return “<h3>Our Custom Header</h3>”;
}

function overrideCustomFooter() {
return “<h3>Our Custom Footer</h3>”;
}

I expect to see a header and a footer display and they are not.

1

There are 1 best solutions below

2
On

Insert script editor webpart into the page and insert the script into script editor webpart(use correct 【"】).

(function () {
var overrideContext = {};
overrideContext.Templates = {};
overrideContext.Templates.Header = overrideCustomHeader;
overrideContext.Templates.Footer = overrideCustomFooter;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
})();

function overrideCustomHeader() {
return "<h3>Our Custom Header</h3>";
}

function overrideCustomFooter() {
return "<h3>Our Custom Footer</h3>";
}

enter image description here

enter image description here

Update:

Have you enabled Minimal Download Strategy?

enter image description here

enter image description here

JSLink won't work if url like /_layouts/15/start.aspx# , you could disable the feature.