Like everything related to Backbone, this is a rather subjective question. But here are a few reasons you might want to give it to your parents:
It is perfectly reasonable to think that the parent view may need to make sure that the child views are displayed before the rest of the rendering. For example, a parent may require the size of a container element based on the size of its children or show the container only after its contents are displayed by child views.
The initialization rendering template only works if you donβt need to do other things at first - for example, one common template for attaching the view to the change model event, calling this.model.fetch() and rendering in the callback. In this case, especially if you care about the execution order of the different renders, itβs nice to have one event listener for the parent, and then have a parent transaction with rendering for the children, instead of having bindings to each child, although these children wonβt cause fetch() .
In addition, if parental rendering does not allow children to reverse themselves, for example, in response to more specific events. Having a parent call to child.render() just helps make sure that this happens by the time the parent has finished rendering.
It's also worth noting that views have a default no-op for render . Thus, the parent can call render() for the child, not being sure that he will do something.
In response to the question: βWhat if a parent changes a child model?β, One option is to not do this β always create a new child for each new model. But this may not match your architecture - in this case, having a parent responsible for re-rendering makes sense.
nrabinowitz
source share