-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
WIP Reimagining Region #3157
WIP Reimagining Region #3157
Conversation
Regionifying CollectionView not part of this? I am seeing more implicit region related issues with using regions as a way to append to rather than remove. It seems like people (maybe) want to do, aside from showChildView, is a setChildView('region', view')
I think we can do this now if we allow but the issue with that is: how do I get the a region's view? |
I think that is just |
replaceChild is https://github.com/marionettejs/backbone.marionette/blob/master/src/region.js#L184 new View({
el: this.getRegion('region').el
}); Which is similar to how I (maybe?) solved for #3150 (comment) |
I guess I just don't know why you'd want to set the region's el as the view's el. It seems backwards if it is the life-cycle container. I think it's still just MyView.extend({
ui: {
foo: '.some-selector'
},
regions: {
region: '@ui.foo'
},
onRender(){
const myChild = new Mn.View({ el: this.ui.foo });
this.showChildView('region', myChild, {replaceElement: true});
}
}); |
The way I defined it preserves the contents. example <table data-ui="table">
<thead>
<!-- don't remove me, bro -->
</thead>
<!-- collection will be appended here -->
</table> new CollectionView({
collection,
el: this.ui.table[0],
childView: TBodyView
}); this allowed for the thead to be kept while being able render the models with |
At that point, what is the purpose of having the region in that at all? |
Like the Region class binding to the DOM? Nothing, now that you point that out. I always saw Regions as place holders/markers for rendering *View classes. What I didn't like was all the wrapping that came with showChildView, and in some cases I use the example I gave. |
I think a Region's main goal is handling the lifecycle events. I think that once you want some DOM and a view inside a "region" you now have a CollectionView. What I don't want to start supporting with a single region is: <table data-ui="table">
<!-- a view get's appended here -->
<thead>
<!-- don't remove me, bro -->
</thead>
<!-- a different view get's appended here -->
<!-- a completely different view get's appended here -->
</table> or even just <table data-ui="table">
<!-- a view get's appended here -->
<thead>
<!-- don't remove me, bro -->
</thead>
</table> |
yeah, that looks like a massive nightmare to support. Also, fragile. All thought provoking ideas, is all. |
Closing this for now. This PR did it's job mostly.. will reinvestigate when other things start to shake out. |
This is a breaking WIP.. And it is a long way out.. just wanted to start the conversation.
Essentially the main idea will be to reduce the region API a lot. Much of that is possible by changes to the region mixin..
The next steps possibly will be to modify the region mixin so that regions are instantiated with an
el
at the momentgetRegion
is used instead of at view instantiation. Then instead of resetting regions we can destroy and re-instantiate them on render.And further we'll possibly be able to detach the views within the regions.. we can attempt to recreate known regions after render and reattach views.
This would also allow for further abstraction of regions where we could allow for
this.showChildView(this.ui.someRegion, myView);
or eventhis.showChildView('.some-selector', myView);