Closed jamesladd closed 8 years ago
Your situation is something I've thought about. It is not something that I've actually encountered in an application with Maria; however, it is inevitable and I know I will one day. This is why building the child views is isolated to a method buildChildViews
. That way the child appending behaviour can be overridden.
I think that a child view shouldn't ever care where it is inserted in a parent. The child shouldn't even know what the parent view is. Somehow the parent should know where to put the child.
I think you should override buildChildViews
in your parent view so that the parent can choose where to append children. If you really think that your child views should be asked by the parent where to insert the child views then you can do that in your parent view's overriding buildChildViews
.
We are not really saying the child should know, rather we want a clean way for the parent to associate a child view with where the child view should be anchored in the DOM.
We will investigate buildChildViews further.
Can you share how you overwrote buildChildViews
?
Please reopen if you'd like to continue the conversation.
We would like to be able to tell a parent view where to append a child view with more control.
Currently you have this:
Would it be possible to change line 4 to ask the child view where it should be appended and if not specified by the child only then chooses the this.getContainerEl() ?
For example:
4 this.getContainerEl().appendChild(childViews[i].build(), toolbarElement());
This would help us in situations like this:
And we want the child view to be in one of 'column1' or 'column2' or 'toolbar' rather than all being siblings inside of 'a' (current functionality)