learning_basics_backbone
learning_basics_backbone copied to clipboard
Error in chapter 4 - validate doesn't work
there's no "false" returned or error in the console unless you put {validate: true} on set func....
like
person.set('age', -1, {validate: true}); Age must be positive false
Grabbed from http://www.codebeerstartups.com/2012/12/4-adding-validations-in-models-in-backbone-js-learning-backbone-js/
var person = new Person; person.get('age')// will return 23 as default value person.set('age', -1)// will return false and value ie -1 will not be set
person.on('error', function(model,error){ console.log(error); // printing the error message on console. });
Yeah, just to confirm I'm still getting the same as above.
Also in the post like 9 is written if ( attributes.age < ){ instead of if ( attributes.age < 0){
Though i realise this is an old tut now, not sure if it's still maintained?