Skip to content

Instantly share code, notes, and snippets.

@marklit
Forked from amccloud/gist:2663112
Created May 27, 2012 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklit/2804079 to your computer and use it in GitHub Desktop.
Save marklit/2804079 to your computer and use it in GitHub Desktop.
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"
}
})
});
// Previously you had to use a slightly more verbose approach
// and had to remember which attributes were objects or models.
song.get('album').get('release').year
// Using dot-syntax
// Deep model attributes
song.get('album.title'); // "Sgt. Pepper's Lonely Hearts Club Band"
// Deep object attributes
song.get('album.release.year'); // "1987"
// Regular attributes
song.get('title') // "Lucy In The Sky With Diamonds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment