Gravatar for sohelsd@gmail.com

Question by sohel, Nov 19, 2016 1:52 AM

Iterating over array in underscore

Being new to underscore. I am struggling a bit here in looping through a computed field value and placing the markup on my modified SearchView.cshtml.

Basically the productimages field consists of image urls in an array like ["/image1.jpg","/image2.jpg"]

<div class="carousel-inner">
    {{ _.each(JSON.parse(raw.@(Model.ToCoveoFieldName("productimages", false))) , function(image) { }}
        <div class="item active">
            <div>
                <img class="center-block" src="{{-image}}" alt="">
            </div>
        </div>
    {{ });}}
</div>
1 Reply
Gravatar for sohelsd@gmail.com

Answer by sohel, Nov 19, 2016 2:51 PM

I was able to solve this. There was a typo, I had to use {{=image}} instead.

Ask a question