Skip to content

Instantly share code, notes, and snippets.

@wictorwilen
Created January 30, 2015 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wictorwilen/f242d06bad65eea4403f to your computer and use it in GitHub Desktop.
Save wictorwilen/f242d06bad65eea4403f to your computer and use it in GitHub Desktop.
Change the "new item" link in SharePoint 2013 using CSR with MDS support
// Modify the lines with TODO comments below
Type.registerNamespace('Wictor')
Wictor.Demos = Wictor.Demos || {};
Wictor.Demos.Functions = Wictor.Demos.Functions || {}
Wictor.Demos.OnPostRender = function (context) {
var wpTable = $get("Hero-" + context.wpq);
if (wpTable != null) {
var children = wpTable.getElementsByTagName("a");
for (var i = 0; i < children.length; i++) {
if (children[i].getAttribute("id") == "idHomePageNewItem") {
// TODO: Modify and set your own custom "new item" text
children[i].children[1].innerHTML = "NEW PROJECT";
break;
}
}
}
}
Wictor.Demos.Functions.Register = function () {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(Wictor.Demos)
}
Wictor.Demos.Functions.MdsRegister = function () {
// TODO: Modify the relative path and name of the JS file (or keep the filename and add the file into Site Assets in the site collection)
var thisUrl = _spPageContextInfo.siteServerRelativeUrl + "/SiteAssets/changeTitle.js";
Wictor.Demos.Functions.Register();
RegisterModuleInit(thisUrl, Wictor.Demos.Functions.Register)
}
if (typeof _spPageContextInfo != "undefined" && _spPageContextInfo != null) {
Wictor.Demos.Functions.MdsRegister()
} else {
Wictor.Demos.Functions.Register()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment