I was curious if there was a way for me to set a collections model to a parent model. I may be way off here as I’ve just started with backbone.js but heres the structure I’m looking to do.
Collection
model:object
the object model is the parent model of two other sub-objects.
Object
->Image
->text
The two sub models extend the Object model.
Is this do-able? I hope I am making myself clear here. Thanks to anyone who can offer any assistance.
Yes, this is doable.
I haven’t used different subclasses in a collection myself, but here is a quite nice article about Backbone inheritance in general as well as “Subclasses in a Super Collection” in particular.
After setting up the inheritance itself the author uses the collections parse function to create corresponding models.
Regarding the inheritance part you might also wanna take a look at this question and JohnnyO’s answer which might help your code design and avoid calls like