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