Skip to content

Instantly share code, notes, and snippets.

@mspanish
Created August 20, 2013 03:56
Show Gist options
  • Save mspanish/6276958 to your computer and use it in GitHub Desktop.
Save mspanish/6276958 to your computer and use it in GitHub Desktop.
jQuery(function() {
// Create our namespace and related organizers
window.DartsLeague = {};
DartsLeague.Models = {};
DartsLeague.Collections = {};
DartsLeague.Views = {};
DartsLeague.TourneysApp = new Backbone.Marionette.Application({});
/********************************************
* Models and Collections
********************************************/
// Member model/collection
DartsLeague.Models.Member = Backbone.Model.extend({
});
DartsLeague.Collections.Members = Backbone.Collection.extend({
model: DartsLeague.Models.Member
});
// Team model/collection
DartsLeague.Models.Team = Backbone.Model.extend({
initialize: function(){
var teamMembers = new DartsLeague.Collections.Members(this.get("teamMembers"));
this.set("teamMembers", teamMembers);
}
});
DartsLeague.Collections.Teams = Backbone.Collection.extend({
model: DartsLeague.Models.Team
});
// Game model, no collection
DartsLeague.Models.Game = Backbone.Model.extend({
});
// TourneyGame model/collection
DartsLeague.Models.TourneyGame = Backbone.Model.extend({
initialize: function(){
var game = new DartsLeague.Models.Game(this.get('game'));
var teams = new DartsLeague.Collections.Teams(this.get('teams'));
this.set('game', game);
this.set('teams', teams);
}
});
DartsLeague.Collections.TourneyGames = Backbone.Collection.extend({
model: DartsLeague.Models.TourneyGame
});
// Tourney model/collection
DartsLeague.Models.Tourney = Backbone.Model.extend({
initialize: function(){
var tourneyGames = new DartsLeague.Collections.TourneyGames(this.get("tourneyGames"));
this.set("tourneyGames", tourneyGames);
}
});
DartsLeague.Collections.Tourneys = Backbone.Collection.extend({
model: DartsLeague.Models.Tourney,
url: './assets/json/mock-darts-tourneys.json'
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment