سؤال

I have a picture library in SharePoint 2016 with the ratings enabled. I want users to be able to rate each picture in the library. In the display view, just the image icon shows and not the actual picture.

Users would have to click the icon to see the image and then hit the back button to rate the image. I want to show the image on the view so that there will be no drill down to see the picture. I created the below JS link to convert the icon to the image but I get an error that makes no sense.

The error I get in the console shows:

SCRIPT1006: Expected ')'

(funciton() {
    var nameFieldContext = {};
        nameFieldContext.Templates = {};
        nameFieldContext.Templates.Fields = {
            "Name": {"View": renderImageToRate }
        };
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(nameFieldContext);
})();  //<---- error points to this line

function renderImageToRate(ctx){
alert("In function");
    var name = ctx.CurrentItem.Name;
    
    return "<img src='../pictureLib/'"+name+">";
}

The code looks fine to me. Any ideas?

هل كانت مفيدة؟

المحلول

Your code looks fine to me as well. But I noted there is small syntax error in your code in 1st line.

You misspelled the function keyword. Try correcting it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top