View Full Version : [OPEN] 2 instances of controllers if I don't specify the full name in app.js

27 May 2015, 9:28 AM
I have 2 instances of each of my controllers running at runtime. I have this issue in both the Pre-Release and the Beta.

My definition of my controllers is as follows:

In my App.js
controllers : [MyController]

In my Controller:

Ext.define('MyApp.controller.MyController', {
extend: 'Ext.app.Controller',
config: {
views: [MyPane],
refs: {
myPane: '#mypane'
control: {
'#mypane': {
activate: 'onMyPaneActivate'
onMyPaneActivate: function(container) {
//This is fired twice.
// first time: this._id and moduleClassName === 'MyController'
// second time: this._id and moduleClassName === 'MyApp.controller.MyController'

If I change app.js to be:
controllers : [MyApp.controllers.MyController]
Then, the issue does not occur. According to the docs here:
I shouldn't be required to specify the full name of the controller.

1 Jun 2015, 12:28 PM
I'm not able to reproduce. Running this fiddle in last night's nightly build there is only one controller created:


1 Jun 2015, 12:31 PM
I found that this.controllers.getCount was accurate. It was the event raise firing twice w/2 different 'this' values that suggested there were 2 loaded. I'll play with a small project to see if I can repro.

1 Jun 2015, 3:10 PM

Took me a while, but on Ext6 you'll get 2 popups... on Touch 2.4.1 you'll get 1 popup.

I believe it's related to the full name being specified in the getController call...

2 Jun 2015, 2:34 AM
In that fiddle it's because of this line:


The ID the controller is getting is 'MyPaneController' so if you changed it to


then everything will work as you expect.

The getController call will create a new instance if a controller is not currently found which in your test it doesn't find a matching controller.

2 Jun 2015, 6:32 AM
Yup, I realize that it should just be 'MyPaneController' instead of the Full name.

The only reason I stumbled on it was that someone did this in our code at some point, no one caught it in a code review, and it didn't have a side effect in Touch 2.4.1. But now that I'm porting over to Ext6, it does something different (2 controllers vs 1).

I'll obviously correct the code. Since it's a change between Ext6 and Touch2.4.1... it does leave it open for mistakes like this to happen.

11 Sep 2015, 12:30 PM
Hate to bring an old thread back, but now that I've picked up ExtJS 6.0.1, I had to go through all my code and change it back to the full (long) name, since the short name was now creating a new controller instead of giving me the existing one.

14 Sep 2015, 11:08 AM
stumbled upon the same issue on a client project.

looking at the mixed collection of MyApp.controllers shows a key of undefined for each one (they are defined inside the controllers array of the app, short names., classic

need to take a closer look what is going on here, but if the framework tries to get controllers by key it could explain the multiple creation.