0
我正在加载使用骨干网页的所有帖子。并在点击“获取所有评论”链接时加载评论。我收到来自Ajax调用的所有评论。Backbone.js - 从视图渲染数组,无需在模板中创建循环
Social.Views.StreamsIndex = Backbone.View.extend({
comment_template: JST['streams/comment'],
comment_displayall: function(data, post_id) {
this.$("#comments").html(this.comment_template({
comment: data // Here data is array
}));
}
});
我comment.jst.ejs文件其现在有一个循环,但我不得不把它放在视图
<% _.each(comment.comments,function(comment){ %> // I want to get rid of this Line
<div class="stream_comment">
<div class="stream_commentphoto">
<a><img src="<%= comment.actor.thumbnail.url %>"></a>
</div>
<div class="stream_comm-content">
<a href="#"><h5><%= comment.actor.displayName %></h5> </a>
<p><%= comment.content %></p>
</div>
</div>
<%}%>
我怎样才能摆脱循环的评论模板中,通过在视图中添加循环?
谢谢..这工作.. .. – 2013-04-23 10:55:55