Given a View like:
<div id="comment-100">
<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.Attachments }'> </ul>
</div>
<div id="comment-102">
<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.Attachments }'> </ul>
</div>
<div id="comment-103">
<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.Attachments }'> </ul>
</div>
<div id="comment-104">
<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.Attachments }'> </ul>
</div>
<div id="comment-105">
<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.Attachments }'> </ul>
</div>
What I would like to do is update the data-bind, to do something like foreach: attachmentsModel.Attachments.where(attachmentsModel.Attachments.comment_id == 105). Allowing me to only show the attachments tagged to that comment.
I thought about just adding an {if} condition inside the jquery Template, but that won't work as I only want to render that template once on the page, while the comments above are rendering by looping through an array.
Any suggestions? Thanks