View Full Version : Using multiple controller on the same viewport

14 Aug 2012, 4:52 PM
I'm using ExtJS 4.1 and I have some trouble with the MVC approch. I have the following questions:

I have a viewport witch contain 2 containers, I want to associate a controller for each container, but the problem is that each controller 'take the control of all the application'
Is it possible to have 2 container in the same viewport that contains each a component with the same id?
When I destroy a view (using myView.destroy();) and a controller (using myController = null;) and then I reload a new view with the same components (same ids), I notice that the listeners are still loaded
My aim is to have a controller that take control of a limited area in the viewport.
I'm using this to add a listeners

'#buttonID' : {click: this.onButtonClick}

Thanks in advance

14 Aug 2012, 6:45 PM
1. All controllers in an application will use the same eventbus to catch events from components and do the respective handling. Because of using the same eventbus so controller has affected to all components in application.

2. With the current implementation of Ext framework, once controller has been loaded, it will exist as long as the application exists. There is no way to destroy loaded controller.

3. Controller use control() method to register event handlers to the application eventbus, but up to now, there is no method to remove event handlers from eventbus.

4. You could use the same itemId for components in your application, provided that they are not in the same container. However, you could not use the same id for components because id is required unique on HTML document.

5. To isolate the scope of a controller in application, you should use more specific selectors to define components it will be responsible to. For example, instead of just use select with '#buttonId', you should use selector '#container1Id #buttonId' for button on container1 and '#container2Id #buttonId' for button on container2.

15 Aug 2012, 2:25 AM
Thank you too much vietits, that was relevant. Now I have clear ideas =D>