我有一个骨干模型,其中包含验证对象和验证参数列表。
var SignUpModel = Backbone.Model.extend({
validation: {
firstname: {
required: true,
pattern: 'name'
},
lastname: {
required: true,
pattern: 'name'
}
},
addToValidation: function(){
// HOW TO DO THIS???
this.validation.PUSH{
country: {
required: true
},
phone: {
required: true,
pattern: 'phone'
}
}
}
});
如何将另一个对象添加到此对象?我在JS中找不到它,但是这个函数可能存在于Backbone或Underscore中吗?
也许骨干网有特殊的数据保存功能?
答案 0 :(得分:2)
_.extend(this.validation, {
country : {
required: true
},
phone: {
required: true,
pattern: 'phone'
}
});