JSFiddle - React, Tailwind, and code Playground
by softvar
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.0/backbone-min.js"></script>
JavaScript
Person = Backbone.Model.extend({
defaults: {
name: 'Fetus',
age: 0,
child: ''
},
initialize: function(){
alert("Welcome to this world");
this.on('change:child',function(m){
alert(m.get("child"));
});
},
adopt12: function( newChildsName ){
this.set({ child: newChildsName });
}
});
var person = new Person({ name: "Thomas", age: 67, child: 'Ryan'});
person.adopt12('John Resig');
var child = person.get("child"); // 'John Resig'
console.log(child);
SearchView = Backbone.View.extend({
initialize: function(){
alert("Alerts suck.");
}
});
// The initialize function is always called when instantiating a Backbone View.
// Consider it the constructor of the class.
var search_view = new SearchView();