我通过addyosmani获得了基于骨干基础的验证,但是当我在我的视图上尝试它时,我无法得到模型生成的错误.TIA
model.js
validate: function(attrs) {
var errors = this.errors = {};
if (!attrs.box)
errors.box= 'box value is required';
//console.log(errors.box);
if (!_.isEmpty(errors)) return errors;
}
view.js
validate: function(model) {
console.log("error text--" + model.errors[this.input] || '');
},
答案 0 :(得分:0)
应该是var errors = this errors || {} ;
吗?