-1
У меня есть вид Backbone, который выглядит так:Backbone ReferenceError
App.Views.HistoricalDataSelector = Backbone.View.extend({
initialize: function (options) {
this.template = JST['backbone/templates/historical_data_selector'];
this.collection = options.collection;
this.model = options.model;
this.render();
},
myCollection: function() {
return this.collection.byReportType(this.model.get('report_type')).byReportOrganizationType(this.model.get('report_organization_type'))
},
render: function() {
this.$el.html(this.template({
collection: myCollection,
model: this.model
}));
}
});
, когда я пытаюсь сделать это Backbone возвращает мне следующую ошибку:
ReferenceError: myCollection is not defined
Но когда я изменить метод отрисовки к этому:
render: function() {
this.$el.html(this.template({
collection: this.collection.byReportType(this.model.get('report_type')).byReportOrganizationType(this.model.get('report_organization_type')),
model: this.model
}));
}
Почему он не может найти этот метод myCollection?
это будет указывать на текущий объект вида. – Prateek