Miscellaneous Backbone Models
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
computed properties
.gitignore
README.md

README.md

backbone-misc

Miscellaneous Backbone Models with random utilities thrown in

BaseComputedModel.js

This lets you have computed properties in Backbone.

    var myModel = BaseComputedModel.extend({
        defaults: {
            firstName: "John",
            lastName: "Smith",

            fullName: function(){
                    return this.get("firstName") + this.get("lastName");
            }
        }
    });

    console.log(myModel.get("fullName")); //Print John Smith
    myModel.set("firstName",  "Jane");
    console.log(myModel.get("fullName")); //Print Jane Smith

You can also bind on computed properties, and pretty much just treat it like you would any other property

    myModel.on("change:fullName", function(){
        console.log("Full name changed");

    });

TODO:

Add tests