0

Created by field is formatted as "name". Field ref used in jslink ctx override is:

 ...<span>Submitted by: " + ctx.CurrentItem.Author + "</span>...

Field is present in view but all I get is "object Object". It does work when list body only is formatted, so seems to be related to formatting the header element.

Update:

(function () {


var overrideCtx = {};
overrideCtx.Templates = {};


overrideCtx.Templates.Header = "<div class='slider3'>";
overrideCtx.Templates.Footer = "</div>";



//       Register the template overrides.

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);

})();


function CustomItem(ctx) {

var ret = "<div class='slide'><a target='_blank' href='/cookbook/Lists/Posts/Post.aspx?ID=" + ctx.CurrentItem.ID + "'>"
 + ctx.CurrentItem.Image_x0020_upload + "<h5 class='event-title'>" + ctx.CurrentItem.Title + "</h5></a><span>Submitted by: "
 + ctx.CurrentItem.Author + "</span><br />" + ctx.CurrentItem.Body + " </div>";
return ret;
}
  • Can you share some more of your code? – Dylan Cristy Nov 16 '15 at 19:54
4

I just did a quick test, and it seems like ctx.CurrentItem.Author is actually an array:

enter image description here

So you might want to try this:

...<span>Submitted by: " + ctx.CurrentItem.Author[0].title + "</span>...

  • That did it. Awesome! – matt Nov 16 '15 at 21:38

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.