Skip to content

Instantly share code, notes, and snippets.

@Breefield
Created August 9, 2012 20:42
Show Gist options
  • Save Breefield/3307872 to your computer and use it in GitHub Desktop.
Save Breefield/3307872 to your computer and use it in GitHub Desktop.
Game Model in Backbone.js
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