I have been trying to create a simple JSLink Script that renders a image depending on what is selected in the Favorites field. I am relatively new to JS Link and may be making a simple syntax error. Any guidance is greatly appreciated.
at this time I am getting no response. I have written jslink before so its not a js location problem.
(function () {
var Context = {};
Context.Templates = {};
Context.Templates.Fields = {
"Favorites": { "View": FavoritesTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(Context);
})();
// I have a field named Favorites its a choice field with Yes and No
function FavoritesTemplate(ctx) {
var FavoritesField = ctx.CurrentItem.Favorites;
var image = "";
// Select the image source
if (FavoritesField == "Yes"){
image = "~site/ALL%20Images/goldstar.png";
}
else if (FavoritesField == "No"){
image = "~site/ALL%20Images/emptystar.png";
}
else{
image = "~site/ALL%20Images/skull.png";
}
return "<img src = '" + image + "'/>";
}