Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Clean up on control/view removal

$
0
0
hi Justin

Yes I am doing something like that in my app, putting the deferreds in an array and calling abort on them.

But my question is really what is the best practice for doing clean up like this on controls?

Say I have an app with a control that acts as a router, in each route the control instantiates a sub control (using the same DOM element for the view), if you change the route I want to clean up existing controls.

So a way to do it is to keep a reference to the sub-control and the call destroy on it before instantiating the new sub-control.

But I'm wonder if there is some listener in can.Control that can listen to its view removed from the DOM and do the clean-up there, a more self container approach.

Viewing all articles
Browse latest Browse all 3491

Trending Articles