我有一个非常基本的设置,如下所示:
var MusicModel = Backbone.Model.extend({});
var PlaylistCollection = Backbone.Collection.extend({
model: MusicModel,
events: {'add':'add'},
add: function(mdl){
//This is working perfectly fine even output of model
console.log(mdl);
}
});
var playlistCollection = new PlaylistCollection();
playlistCollection.add(new Music(data));
该模型实际上并未添加到集合中。如果我尝试使用 Chrome 控制台并输入playlistCollection.length
,它将输出 0 并playlistCollection.models
输出[]
.
知道我做错了什么吗?