I have an Alloy app structured with a one window divided in two views: a sidebar menu view on the left and a main view on the right. Each time the user click on a different menu-item in the sidebar I remove all children attached to the main view and load the view/controller related to that menu-item and attach it to the main view. My question: is this sufficient? If the removed view had event listeners attached to elements inside it, are they clean up too or not? Have I to keep a reference to each controller I have instantiated and call controller.destroy() and controller.off() before I load the new view/controller or is not necessary?
I am asking because with views without window is not possible to attach a cleanup function to the "onclose" event because the UI.View elements can't be "closed" (only windows).
So which is the correct way to handle this situation in Titanium?