fla*_*unk 2 javascript jquery backbone.js
我在这里设置了一个问题的jsBin:http://jsbin.com/oSIJunu/2/edit?html,js,console,output
由于渲染函数(friendView.render().el)上el属性的问题,Collection视图无法渲染.
该视图如下所示:
var FriendListView = Backbone.View.extend({
render: function(){
this.collection.forEach(this.addOne, this);
},
addOne: function(friendModel){
var friendView = new FriendView({model: friendModel});
this.$el.append(friendView.render().el);
}
});
Run Code Online (Sandbox Code Playgroud)
你需要this从render链接功能返回.
render: function(){
this.collection.forEach(this.addOne, this);
return this;
},
Run Code Online (Sandbox Code Playgroud)