I have two templates:
<script type="text/template" id="todo-template">
<label class="todo-content"><%= content %></label>
<ul class="comment-list" style="margin-left: 2em"></ul>
</script>
<script type="text/template" id="comment-template">
<label class="comment-content"><%= content %></label>
</script>
a template for a post and a template for a comment within a list of the post item. How do I add comments to the right post if there are many different posts. I can’t just use
$("ul.comment-list").append(commentView.render().el);
in order to append a comment to a post, since it will add comments to all posts. How do I address the corresponding comments-list of the different todo-templates?
It depends on how you are keeping track of your posts. If you have a view for each of your posts then in the view you can reference the right
ulthrough it’s$el,Edit:
Looking at your code I see that each Todo has a child collection view, so what you can do is simple pass in the the right el when you instatiate the collection view,
Then in your collection view you can just append it to its el