-
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
Marionette regions needs a preventReRender
option
#2328
Comments
|
ugh the region api keeps growing and growing :( |
I was originally in favor of adding this option, but I think a more forward-thinking approach would be to refactor show: function (view, options) {
var shouldDestroyView = this.shouldDestroyView(view, options);
//...
if (shouldDestroyView) {
this.renderView(view, options);
// ...
}
// ...
} To solve this particular problem, you could override renderView on a special region. var CachingRegion = Marionette.Region.extend({
shouldDestroyView(view, options) { return false; },
renderView(view, options) {
if (!view.isRendered) { view.render(); }
}
} For v3, this also affords us gives us some room to remove a bunch of these ugly options, instead giving users a more flexible API. |
Hi @cmaher, I totally agree with you 👍 . Allowing the developer to control this "prevent re-render" behavior by creating a specialized Marionette Region is much more flexible. |
solution provided in #2335 added in |
Great, thanks for this, we'll try it on our next Marionette app 😃 |
Hi, I have a use case where I need a region to attach / dettach multiple views without rerendering those views on 2nd, third, fourth, etc...
Region.show()
calls.Here is a fiddle to explain what I need : http://jsfiddle.net/g7kzpe2p/3/, and the code of this fiddle here.
This samples shows that a Marionette Region is always re-rendering its views even if the
preventDestroy
option istrue
.In our case this is problematic because our
View1
andView2
views are huge and have to be cached after a first Regionshow
is called.After talking to @cmaher on gitter it appears that adding a
preventReRender
option to the Marionette region could be a good idea to have a behavior similar toView2
in my sample.The code to show our views would be :
Any thoughs about that ?
The text was updated successfully, but these errors were encountered: