Access deep Backbone.js model attributes with dot-syntax.
JavaScript
Latest commit d942612 May 14, 2012 @amccloud Fixed formatting.
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE
README.md
backbone-dotattr.js

README.md

Backbone Dotattr Build Status

Access deep Backbone.js model attributes with dot-syntax.

Example

var song = new Backbone.Model({
    title: "Lucy In The Sky With Diamonds",
    album: new Backbone.Model({
        title: "Sgt. Pepper's Lonely Hearts Club Band",
        release: {
            year: "1987"
        }
    })
});

// Deep model attributes
song.get('album.title'); // "Sgt. Pepper's Lonely Hearts Club Band"

// Deep object attributes
song.has('album.release.year'); // true
song.get('album.release.year'); // "1987"

// Regular attributes
song.get('title') // "Lucy In The Sky With Diamonds"

Supported Methods

  • get
  • escape
  • has