-
Notifications
You must be signed in to change notification settings - Fork 102
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
Prevent zombie view in router.js #11
Comments
Thanks Thomas, you are exactly right. I am working on the View Manager write now that controls the life cycle of views and stops zombie views, will be pushing in the next few hours. Thanks again! |
Hi, I think it would be a nice improvement when we return 'this' on the render method. ChildPage = Backbone.View.extend { Sometime, from master page we want to append a child page, we could do: |
I've also had issues with the current View Manager, which, while great, doesn't clean up properly. I came across this after loading views where events defined in (events.js) were being triggered multiple times. To work around this, I'm using undelegateEvents() on the previous view before creating a new one. I'm aware that the VM isn't fully implemented yet, but any plans on setting this up? |
on second thought undelegateEvents is probably the only default cleanup a view manager should do and also calling clean() if it has been defined. What do you think? |
I'm certainly no expert, but that's just what I'm doing! Sounds good :) Also, on the subject of VM - is it supposed to re-use already created views when called again? As currently, it doesn't seem to, and just creates a new view when create is called. In fact, views[name] is never defined. Thanks for your quick response by the way! |
So in the view manager the views should always be created fresh, if you want to maintain a view you can do so using your applications logic. Some goals I had for the view manager were
For now I've changed the unbind() to undelegateEvents(). |
Ok, that clears that up - sounds good. Thanks mate! |
Hi,
Thanks for creating the boilerplate, I really like it. This is just minor suggestion to prevent zombie view in the file router.js
Currently we always create a new view when user navigate to different url, and never close or reuse them properly.
E.g:
optimize: function () {
require(['views/optimize/page'], function (OptimizePage) {
var optimizePage = new OptimizePage();
optimizePage.render();
});
},
I think a better approach is to check whether the page is already been initialized, then we can reuse it efficiently without creating new page every time. For e.g:
if (! this.optimizePage) {
this.optimizePage = new OptimizePage()
}
this.optimizePage.render()
The text was updated successfully, but these errors were encountered: