Created
July 3, 2014 02:46
-
-
Save lunks/f2ba5be7049135eb0d7e to your computer and use it in GitHub Desktop.
Backbone Collection with subModels using backbone-relational (not working)
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
Dashboard.module 'Entities', (Entities, Dashboard, Backbone, Marionette, $, _) -> | |
class Entities.Site extends Backbone.RelationalModel | |
relations: [ | |
{ | |
type: Backbone.HasMany | |
key: 'widgets' | |
relatedModel: 'Dashboard.Entities.Widget' | |
parse: true | |
relatedCollection: 'Dashboard.Entities.WidgetCollection' | |
reverseRelation: { | |
key: 'site' | |
includeInJSON: Backbone.Model.prototype.idAttribute | |
} | |
} | |
] | |
class Entities.SiteCollection extends Backbone.Collection | |
url: '/dashboard.json' | |
model: Entities.Site |
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
Dashboard.module 'Entities', (Entities, Dashboard, Backbone, Marionette, $, _) -> | |
class Entities.Widget extends Backbone.RelationalModel | |
subModelTypes: | |
'numbers': 'Entities.NumbersWidget' | |
Entities.Widget.setup() | |
class Entities.NumbersWidget extends Entities.Widget | |
class Entities.WidgetCollection extends Backbone.Collection | |
model: Entities.Widget |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment