I have a REST Json API that returns a list \"logbooks\". There are many types of logbooks that implement different but similar behavior. The server side implementation of th
Yes. You can override the parse
function on the collection (I'm gonna use javascript instead of coffeescript, because it's what I know, but the mapping should be easy):
LogbookCollection = Backbone.Collection.extend({
model: Logbook,
url: "/api/logbooks",
parse: function(response){
var self = this;
_.each(response, function(logbook){
switch(logbook.type){
case "ULM":
self.add(new UmlLogBook(logbook);
break;
case "Plane":
...
}
}
}
});
Hope this helps.