Skip to content

narenranjit/backbone-misc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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

About

Miscellaneous Backbone Models

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published