Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Miscellaneous Backbone Models
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

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

Something went wrong with that request. Please try again.