I have a BackboneJS collection called History that can contain one of several Backbone JS models (which extend from HistoryItem that extends from Backbone.Model), I'm trying to find a way to restore this on boot, unfortunately it seems that the BackboneJS collection may specify only a specific model, for example
HistoryCollection = Backbone.Model.extend({ model: app.models.HistoryItem })
What I really need to do is define this for each type, this is what I would like to do
HistoryCollection = Backbone.Model.extend({ model: function(item) { return app.models[item.type]; } })
Any ideas before I work with the poppy to implement this? (i.e., an attribute of a collection model that can accept a function)
user53791
source share