Access deep Backbone.js model attributes with dot-syntax.
JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 6 commits ahead of amccloud:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
src
test
.gitignore
.travis.yml
Gruntfile.js
LICENSE
README.md
component.json
package.json

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