-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subview replaces container rather than become child #87
Comments
I think that if the subview hash contains a |
first off, sorry this has been sitting for so long. I agree that it's confusing the way it's written and that it's a problem. The original thought was that the parent view could basically insert some DOM elements as placeholders. Since when you In that I never considered the use case of wanting to push to subviews into the same container without them being part of a collection. In this particular case, since you have a known number of subviews, couldn't you simply create placeholder elements for each subview, with different ID or data-hook. I guess what I'm asking is, if you think we should change the behavior or the docs and the name |
I hear you and I do largely agree. Creating placeholders for each subview adds an additional and unnecessary maintenance burden (Want to add another subview in a container? Go add another placeholder too!). In my opinion Now, it might be confusing to have two behaviors for inserting subviews. But I think it makes sense and the documentation could be fairly straightforward. It seems to me though that subviews overall is kind of a confusing topic at the moment! So straightening things out a bit is probably a good idea :) |
@HenrikJoreteg, to answer your question, I would suggest that the behavior should be changed to be consistent with how the term "container" is used throughout the framework. For me, I like to take the long term view - that is, the framework is still young, so it's best to tighten things up now so that people aren't stumbling on confusing bits 5 years later. |
My confusion stemmed from the fact that I'm not sure I mind which way the decision turns, but please have it be consistent across all subview handling code. |
i've had to design around this as well. it's definitely do-able. in my case, i've wanted to bind listeners to an element that 💨 (whoosh) disappears 💨 once I render a view on it. as a consequence, in a my parent's view definition, I then need to know about my child view's hooks to bind the parent view's desired handlers. i like the my workaround (ref'ing child hooks) could admittedly be an anti-pattern. such listeners perhaps could be bound to my child view's
|
Could this please get some more attention? It's odd to have the subviews hash and renderSubview() work differently. Muddles up the code and template each time I have to remember to match container markup in two places or do something counter-intuitive. +1 for subviews container functioning as a container instead of getting replaced by subview el. |
Just to give this another bump: I was confused by the difference as well, but the confusion is not what irks me most; it's the double maintenance in the view and template. I would therefore also prefer appending to a container (+1 for #132). |
I would add an |
I'm not really a fan of flags, though I will acknowledge that backwards compatibility is much easier to achieve using such a flag. However, it doesn't really help the confusion arising from (the default behaviour of) the |
Fix issue #87 - Subviews hash should append el
The docs state:
I think the renderSubview() function has the right idea - it uses appendChild rather than replaceChild. But re-routing that action() function to use renderSubview didn't work for me because it eventually calls renderWithTemplate - and since it can find a parent it calls replaceChild.
The text was updated successfully, but these errors were encountered: