骨干模型验证错误

时间:2012-10-12 09:12:48

标签: backbone.js backbone-views backbone-events

我通过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] || '');


 },

1 个答案:

答案 0 :(得分:0)

应该是var errors = this errors || {} ;吗?