Created
May 11, 2012 23:36
-
-
Save amccloud/2663112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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