I have developed some modifications against SharePoint list new/edit forms using CSR, as many other times everything works as expected. Code has been tested in two different environments and works.
What I believe that it's happening is that SharePoint is not rendering on the page the associated JS objects and instructions needed for CSR.
All environments are on premises, they are not online.
My code register modifications as usual with code like this (simplified ):
var mods = {};
mods.Templates = {};
mods.Templates.OnPostRender = function() { alert() };
mods.Templates.Fields = {
"Project": {
"NewForm": function() { alert() };,
"EditForm": function() { alert() };
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(hiddenFiledContext);
But callbacks never executes... there are no errors no warnings on console, SPClientTemplates
and TemplateManager
exists and they are not undefined.
Comparing between environments I saw that sites where CSR works, inside html exists some JS like:
var WPQ4FormCtx = {"ListData":{ ... }} // form properties like fields context field values...
var form = SPClientForms.ClientFormManager.GetClientForm('WPQ4');
if (form != null)
form.RenderClientForm(); // i believe that this function internally calls CSR 'magic'
This is code is missing, on one environment, don't know why or hoy to "activate" it
NOTE:
EditorWebPart has CSR Render Mode configuration set to
StandardLayout
.Also on the site people pickers look old they are not client side people picker.
Am I missing something or any feature activation? I thought that CSR works OOTB.
Thanks in advance.