backbone model validation error
Posted
by
koko
on Stack Overflow
See other posts from Stack Overflow
or by koko
Published on 2012-10-12T09:12:48Z
Indexed on
2012/10/15
9:37 UTC
Read the original article
Hit count: 272
I got a validation based on backbone fundamentals by addyosmani, but when i try it on my view i can't get the error that the model generated.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] || '');
},
© Stack Overflow or respective owner