View Full Version : getController does not have consistent behavior

22 Aug 2011, 11:03 AM
We are using getController to dynamically load controllers when they are needed.

Case 1: As a proof of concept and testing tool a menu item was created that would allow selection of a controller from a list that would then fire off the getController call with the controller name. For example this.getController(selectedName) where selectedName is the name of the controller such as LocalContacts.js When done this way through the menu the controller constructor fires and all is well, things are rendered and placed as expected. POC works and testing on individual elements can be done.

Case 2: The final version of the app will use a left side menu with links that will load the appropriate controller. Intially this was done making the links as html anchors and doing an onclick. That didn't work as expected as the context did not know about the controllers. This was changed to make the items buttons and have listeners so that the context would essentially mirror the menu trigger. What happens with this setup is that the controller init firers but NOT the constructor. Note this is not setup as a menu like the top menu.

Why is the constructor not firing in this instance (Case 2)?

The controller has not been used up to this point in either case. The scope of the this.getController is similar (inside a controller) and the params are identical. Due to the scope of the data we cannot load all the controllers on the app launch, there is far too much load at that point.

We are using ExtJS 4.0.2a
Thank you for your assistance in solving this issue.

24 Aug 2011, 6:29 AM
The issue was a custom extend for combobox. Case 1 would allow the selection using the extended combobox before proceeding, thus loading the combobox before proceeding with the getController. Case 2 would execute the getController which would then retrieve the combobox extension before proceeding to the next item.
The solution was to add a Require('myapp.myComboBox') into the launch of the app.js, thus getting the custom combobox into the app.