JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
JavaScript
$(document).ready(function(){
Person = Backbone.Model.extend({
defaults:{
name:"Jane Robot",
age:0,
children:[]
},
initialize:function(){
alert("Welcome to this world");
this.bind("change:children", function(){
alert('hey');
});
},
adopt: function(newChildsName){
var children_array = this.get('children');
children_array.push(newChildsName);
this.set({children:children_array});
this.trigger("change:children");
}
});
var person = new Person({name:"Thomas",age:67,children:['Ryan']});
person.adopt('John');
alert(person.get('children')[1]);
})