Skip to content

Latest commit

 

History

History
47 lines (42 loc) · 857 Bytes

backbone-js.md

File metadata and controls

47 lines (42 loc) · 857 Bytes

Backbone Support

Create backbone models:

namespace("my.app.models", function(model){
    model("Sculpture", {
        name: 'Sculpture Name',
        img: ''
    });
    model("Person", {
        name: 'Michelangelo',
        bornYear: 1475,
        diedYear: 1564,
        aged: function(){
            return this.diedYear - this.bornYear;
        },
        bestSculpture: null
   });
});

Just backbone.js:

var Sculpture = Backbone.Model.extend({
    defaults: {
        name: 'Sculpture Name',
        img: ''
    }
});

var Person = Backbone.Model.extend({
    defaults: {
        name: 'Michelangelo',
        bornYear: 1475,
        diedYear: 1564,
        aged: function(){
            return this.diedYear - this.bornYear;
        },
        sculpture: {
            name: 'Pietà'
        }
    }
})