dhruvaray / backbone-associations

Create object hierarchies with Backbone models; Respond to hierarchy changes using regular Backbone events.
http://dhruvaray.github.io/backbone-associations/
MIT License
492 stars 75 forks source link

Model Inheritance & Polymorphism #168

Open gmcdowell opened 7 years ago

gmcdowell commented 7 years ago

Hi,

I'm trying to employ inheritance over 3 levels for Models that I use in a LogCollection (polymorphism) and have been attempting to use AssociatedModel for the top level model BaseLog and then extend/specialise to suit my needs:

e.g.
- BaseLog
-- WorkingLog
--- DriveLog
--- RestLog
-- CloseLog

The BaseLog has a Backbone.Many relation property of vehicles and when run the related vehicles collection is present in the BaseLog as you would expect, but in aany of the sub-classes (e.g. WorkingLog, DriveLog, RestLog, CloseLog) it is undefined.

Can you offer any tips as all your tests appear to define an Backbone.AssociatedModel for each class and I don't see this type of inheritance anywhere?

Any advice greatly appreciated.