我有以下两条路线。这个按预期工作:
panel:function(){
app.layout.setView("div#content", new Answer.Views.Panel({
collection:this.answers,
useTemplate:"panels/"+path
}));
app.layout.render();
},
这个没有:
parkingNonDowntown:function() {
var panel = new(Answer.Views.Panel.extend(ParkingNonDowntown.Views.Calculator.prototype))({
collection: this.answers,
useTemplate: "panels/requirements/city/parking_non_downtown"
});
app.layout.setView("div#content", panel);
app.layout.render();
},
我可以从前者的模板中访问该集合,如:
<% answers.field_name %>
但是相同的代码在使用第二条路线的模板中提供undefined
。
我不认为该集合在ParkingNonDowntown.Views.Calculator中被覆盖 - ParkingNonDowntown模块只扩展Backbone.View。
this.answers
设置为new Answer.collection()
,如下所示:
// Default collection.
Answer.Collection = Backbone.Collection.extend({
model: Answer.Model,
url: '/answers',
});
我意识到这可能不是足够的信息,但有没有人有任何指针? (如果有帮助,代码为open source。)