Created
August 9, 2012 20:42
-
-
Save Breefield/3307872 to your computer and use it in GitHub Desktop.
Game Model in Backbone.js
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
window.Game = Backbone.Model.extend({ | |
// Must define this for API endpoint | |
urlRoot: '/games', | |
// Set defaults like so | |
defaults: { | |
'players': 2 | |
} | |
}); | |
// If I want to access a collection of games in order to | |
// filter them and map them to views I sue a Backbone.Collection | |
window.Games = Backbone.Collection.extend({ | |
model: Game | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment