Google Groups

Re: Data-Binding, foreach - How to add a condition?


Weekends Feb 23, 2011 3:33 PM
Posted in group: KnockoutJS
Thanks RPN, I think that will work eventually, curious if that's the fastest option? But I can look into that later.

Here's what I did based on your reply:

<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.convAttachments, templateOptions: {current_cmt_id: <%=comment.id%>} }'> </ul>

<script type="text/html" id="attachmentListTemplate">
{{if $item.current_cmt_id == id }}
<li>
<a href="${link}" class="fancyIFrame clearfix">${title}</a>
</li>
{{/if}}
</script>

no luck yet though. Is that look right to you>? thxs