【发布时间】:2016-11-09 15:17:56
【问题描述】:
我有一个父视图(用于汽车引擎),其中包含一个显示选项列表的子视图。其中一个选项是将新集合添加到父视图。
我的子视图初始化函数如下所示:
initialize: function (engine) {
this.engine = engine; //parent object
this.valves = engine.valves; //may or may not be empty
};
然后我有这个方法可以在按下按钮时添加集合(阀门):
addPerformanceValves: function() {
var self = this;
if (this.valves.lentgh == 0) {
this.valves = new ValveCollection();
this.valves.url = function() {
return '/api/engines/auto/performance/parts/' + self.id + '/valves';
}
}
this.$('.performanceParts').show();
}
现在我创建了新集合,如何将它添加到父集合?
【问题讨论】:
标签: javascript backbone.js backbone-views backbone.js-collections