1
我有一个编辑视图,用于在每次单击该元素时创建的主干模型。我遇到的问题是编辑视图需要两个Backbone集合来创建编辑表单(它包含两个<select>
列表)。Backbone.js - 使用子模型构建视图
的观点:
MyApp.elementView = Backbone.View.extend({
events: {
'click .edit': 'editForm',
},
editForm: function(ev) {
var editView = new TimeTrack.Views.EditJob({
model: this.model
// This view needs two more collections
// for the <select> elements
});
...
}
});
实例化视图:
var elementView = new MyApp.elementView({
collection: elementCollection
});
什么是推动所需的集合来编辑视图的最佳方式?我是否需要从elementView的窗体实例化中传递编辑视图的集合?或者有更好的方法来做到这一点?