0

I have two JSLinks on Custom List Webparts on my page -- one for a bootstrap slider, which is working fine continuously, and one for an announcements webpart. The announcements webpart was working fine, until I changed the variable for date from the Created field to a custom calculated field called Date to render the date in a particular format. After that change, the JSLink never rendered anymore even when I reverted back to the previous version. Any thoughts? MDS is not activated. Here is the original code:

    (function () {
    var itemCtx = {};
    itemCtx.Templates = {};
        itemCtx.Templates.Header = "<div class='announcements-wrapper'><ul class='announcements-headings'>"
        itemCtx.Templates.Item = announcements;
        itemCtx.Templates.Footer = "</ul></div>";
    itemCtx.BaseViewID = 1;
    itemCtx.ListTemplateType = 99;
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
    })();

    function announcements(ctx){
        var headliner = ctx.CurrentItesm.Title;
        var body = ctx.CurrentItem.Body;

        var msg = body.replace(/<(?:.|\n)*?>/gm, '');
        var author = ctx.CurrentItem.Author[0].title;
        var date = ctx.CurrentItem.Created;
        var msgLimit = 355;
        var html = "<li><div class='announcements-item'><div class='announcements-date'>" + date + "</div><h2 class='announcements-title'>" + headliner + "</h2> <p>" + msg + "</p><br/>Read More </div></li>";


if (msg.length > msgLimit){
 msg = msg.substring(0,msgLimit);
}
        return html
}

Using SP2013 OnPrem. Also checked that the url was correct and I am using ~site/../..javascript.js in the Misc input box. Note, that I can see that the JS is loading as in Dev Tools, I can see it as a source. I'm really baffled considering it was fine earlier.

2

You have a typo here var headliner = ctx.CurrentItesm.Title; that probably breaks your whole function.

Should be:

var headliner = ctx.CurrentItem.Title;

| improve this answer | |
  • Thank you for the catch! Unfortunately, that still didn't do anything :\. I've found that typically if it is actually loading, there'd be an Uncaught TypeError & the webpart is blank for coding problems. But for some reason, it just loads the list as normal so to me it doesn't seem like it is loading at all. I tested by using the same BaseID as my slider, & only the slider showcased a TypeError until I changed the BaseID again. – user2004758 Mar 1 '19 at 18:58
0

I have found the error. Entered wrong number for the ListTemplateType. Announcements TypeID is 104. This resolved the issue.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.