初始化主干视图时出现以下错误:
this.collection.on is not a function
我有以下观点:
define([
'jquery',
'underscore',
'backbone',
'events',
'utils',
'text!../../templates/vehicles-template.html'
],
function (
$,
_,
Backbone,
vent,
utils,
vehiclesTemplate) {
var VehiclesView = Backbone.View.extend({
template: vehiclesTemplate,
initialize: function () {
this.collection.on('reset', this.render, this); //error: this.collection.on is not a function
utils.log('Vehicles view initialized');
},
render: function() {
this.$el.empty().html(this.template({ vehicles: this.collection.toJSON() }));
return this;
}
});
return VehiclesView;
});
这将返回视图,但在尝试绑定到事件时不会在集合或模型上失败。
我在这里缺少什么?