我在主干问题上没有找到我的视图。这里的代码骨干不初始化视图。 “undefined不是函数”
这里的意见。
App.Views.SummaryTableView = Backbone.View.extend({
tagName: 'tbody',
initialize: function() {
this.childViews = [];
this.collection.on('add', this.addOne, this);
this.collection.on('change reset', this.render, this);
console.log(this.collection);
},
addOne: function (appSummary) {
console.log('should be receiving model');
console.log(appSummary);
var appSumTable = new App.Views.SummaryListView({ model: appSummary });
console.log(appSummary);
this.$el.append(appSumTable.render().el);
this.childViews.push(appSumTable);
},
render: function() {
console.log('rendiring collection: ' + this.collection);
this.collection.each(this.addOne, this);
console.log('sending the model');
return this;
},
close: function() {
this.remove();
this.unbind();
this.childViews = [];
}
});
App.Views.SummaryListView = Backbone.View.extend({
tagName: 'tr',
template: template('app-summary-table-template'),
initialize: function() {
console.log(this.model);
this.model.on('add', this.render, this);
},
render: function() {
console.log('rendering');
var mod = this.model.toJSON();
this.$el.html(this.template(mod));
return this;
},
close: function() {
this.remove();
this.unbind();
}
});
SummaryTableView具有集合,并且视图将模型发送到SummaryListView。集合工作正常,模型包含数据。但由于某些原因,当我运行代码时,它一直说SummaryListView是未定义的。它找不到视图。难道我做错了什么?我得到的错误在这行: var appSumTable = new App.Views.SummaryListView({ model: appSummary });
面对几乎类似的问题,关于这个问题的任何更新? ! – semuzaboi 2015-07-21 11:14:18