3

I'm working on a Content Search WebPart which displays a list of pages. The third line, in my properties, returns a PublishingPageContentOWSHTML.

But is it normal that its value appears twice, once my displayTemplate has finished its job? I'm basically getting the value using:

var line3 = $getItemValue(ctx, "Line 3");

And displaying it in a div. But the result leaves me a bit puzzled;

<div><p>​In blandit diam ligula, [...] purus feugiat auctor.</p>​In blandit diam ligula, [...] purus feugiat auctor.</div>

I plan on trimming the value later of course, I don't want to display a full paragraph in my list but before that, being new to SharePoint, I have no idea what's going on with my value and why it's appearing twice.

  • You can place a debugger and figure out whats going on. – Asad Refai Oct 23 '15 at 10:14
1

Seems your are not getting a value but an object with formatting and innerText.

You can test with:

var line3 = typeof $getItemValue(ctx, "Line 3");

Trace the output to the F12 Dev Tools console

console.info('line3',$getItemValue(ctx, "Line 3"));

you can then inspect of its an Array or an Object with (named) properties.

  • you're right, line3 is an object. But how can I handle this then? I tried casting it to a string but it doesn't change anything, so is it because of the PublishingPageContentOWSHTML ? – Hanayoru Oct 23 '15 at 9:56

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.