Cast/initialize submodels of a Backbone Model

Posted by nambrot on Stack Overflow See other posts from Stack Overflow or by nambrot
Published on 2012-09-10T10:55:04Z Indexed on 2012/09/10 15:38 UTC
Read the original article Hit count: 269

Filed under:
|

I think I have a pretty simple problem that is just pretty difficult to word and therefore hard to find a solution for. Setup:

  • PathCollection is a Backbone.Collection of Paths
  • Path is a Backbone.Model which contains NodeCollection (which is a Backbone.Collection) and EdgeCollection (which is a Backbone.Collection).

When I fetch PathCollection

paths = new PathCollection()
paths.fetch()

obviously, Paths get instantiated. However, I'm missing the spot where I can allow a Path to instantiate its submodels from the attribute hashes. I can't really use parse, right? Basically im looking for the entry point for a model when its instantiated and set with attributes. I feel like there must be some convention for it.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about backbone.js