I have a pretty complicated Backbone Model structure.
- m.Question: is a base question. If this was C++ it would be an "abstract" model because only it's children are ever instantiated
- m.NumericQuestion: extends m.Question
- m.MultipleChoiceQuestion: extends m.Question
- m......Question: you get it lots of question types
- c.Questions: collection of m.Question children
When getting saved to the database they all have an attribute called "type" which decides what model it should be.
When raw questions are retrieved from server, they are placed in a Questions collection (c.Questions). Backbone should parse the response from the server and make the appropriate model based on type.
So I wrote a _prepareModel() function for c.Questions.
But when I do a c.Questions.fetch() I discovered that Backbone.Collection.prototype._prepareModel (the one Backbone relational has) is called first! Is there a way I can intercept the model creation beforehand?