I have a custom list to which I want to apply the JSLink in NewForm.
My code is :
(function () {
// load jQuery
var newscript = document.createElement('script');
newscript.type = 'text/javascript';
newscript.async = true;
newscript.src = '~site/Style Library/JS/jquery-1.11.0.min.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(newscript);
var SPJSScript = document.createElement('script');
SPJSScript.type = 'text/javascript';
SPJSScript.async = true;
SPJSScript.src = '~site/_layouts/15/sp.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(SPJSScript);
var OverrideCtx = {};
OverrideCtx.Templates = {};
OverrideCtx.Templates.Fields = {
"Responsible": {
"NewForm": renderResponsible
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(OverrideCtx);
})();
function renderResponsible(ctx)
{
getResponsibleArray();
return "<b>hello</b>";
}
function getResponsibleArray()
{
alert(_spPageContextInfo.siteAbsoluteUrl);
var clientContext = SP.ClientContext.get_current();
website = clientContext.get_web();
clientContext.load(website);
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
function onRequestSucceeded() {
alert(website.get_url());
}
function onRequestFailed(sender, args) {
alert('Error: ' + args.get_message());
}
}
This code returns Unable to get property 'get_current' of undefined or null reference
error when I debug the JS.
What should I do to get the web to query further in the list and libraries?