Skip to content
Identity map and modelizer for backbone.js
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


backbone.modelizer adds two features to Backbone:

  • Identity map on all models
  • Optional modelizing routines

Identity map

Identity map wraps around all models when instantiating a model such as:

model = new Backbone.Model({id: 8})

Additionaly, you can also do:

model = new Backbone.Model(8)

All models also have retain and release methods, which should be called by the views in order to retain/release their model.

The global function Backbone.IdentityMap.gc() removes all mappings that have not been retained by any view.


Models can define associations:

  Model.prototype.associations: {
    account: {
      model: Account

    licenses: {
      collection: Licenses
      url:        "base/url" (optional)
      scope:      "foo" (optional)

Model.prototype.associations can also be a function.

If model model has association account: { model: Account } then model.account will be defined as an instance of Account and any account attribute returned for model is set on model.account. Meanwhile, model.attributes.account is set to

If model model has association licenses: { collection: Licenses } then model.licenses will be defined as an instance of Licenses and any licenses attribute returned for model is set on model.licenses. Meanwhile, model.attributes.licenses is set to _.pluck account.licenses, "id".

Url parameter sets the url property on the associated collection.

Scope parameter tells the model to add a reference to itself on the collection, e.g. = model


You should include backbone.modelizer.js after including jquery, underscore and backbone.js and before including any of your model classes.

Something went wrong with that request. Please try again.