假设我有以下模型作为我正在制作的表单的基础:
var SomeModel = Backbone.Model.extend({
schema: { --some default things--,
fieldToChange: {type='Select', options=['Default']},
fieldToChange2: {type='Select', options=['Default']}
}
});
现在我想创建一个具有不同创建选项的新 SomeModel:
var formModel = new SomeModel({
//Here's where I don't know how to set just the options of fieldToChange
schema.fieldToChange.options = [A, Computed, Array, Of, Options],
schema.fieldToChange2.options = [A, Computed, Array, Of, Options, 2]
});
var myForm = new Form({ el: $('#elID'), model: formModel};
我可以像这样在创建时更新模型的架构吗?使这项工作适当的方法是什么?