Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Backbone Model Validation And Inheritance

var Song = Backbone.Model.extend({
validate: function(attr)
{
if(attr.title)
return "Title is required";
} 
});

var song = new Song();

console.log(song.isValid());
/*console log true*/
var Animal = Backbone.Model.extend({ 
walk: function(){
console.log("Animal walking…");
}
});

var Dog = Animal.extend({
walk: function(){
Animal.prototype.walk.apply(this);
console.log("Dog walking…");

}
});

var dog = new Dog();
dog.walk();
Source by # #
 
PREVIOUS NEXT
Tagged: #Backbone #Model #Validation #And #Inheritance
ADD COMMENT
Topic
Name
7+1 =