Results 1 to 8 of 8

Thread: 2 instances of controllers if I don't specify the full name in app.js

    You found a bug! We've classified it as EXTJS-19273 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium User
    Join Date
    Apr 2015
    Posts
    97

    Default 2 instances of controllers if I don't specify the full name in app.js

    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:
    Code:
    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:
    http://docs.sencha.com/extjs/6.0/6.0...fg-controllers
    I shouldn't be required to specify the full name of the controller.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    I'm not able to reproduce. Running this fiddle in last night's nightly build there is only one controller created:

    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha Premium User
    Join Date
    Apr 2015
    Posts
    97

    Default

    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.

  4. #4
    Sencha Premium User
    Join Date
    Apr 2015
    Posts
    97

    Default



    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...

  5. #5
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    In that fiddle it's because of this line:

    Code:
    Fiddle.app.getController('Fiddle.controller.MyPaneController').bob();
    The ID the controller is getting is 'MyPaneController' so if you changed it to

    Code:
    Fiddle.app.getController('MyPaneController').bob();
    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.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  6. #6
    Sencha Premium User
    Join Date
    Apr 2015
    Posts
    97

    Default

    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.

  7. #7
    Sencha Premium User
    Join Date
    Apr 2015
    Posts
    97

    Default

    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.

  8. #8
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    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.

    6.0.1.250, 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.

    Screen Shot 2015-09-14 at 21.00.19.png
    Best regards
    Tobias Uhlig

Similar Threads

  1. Replies: 6
    Last Post: 21 Nov 2012, 10:02 AM
  2. can we create Instances of controllers?
    By kabab in forum Ext: Q&A
    Replies: 1
    Last Post: 21 Nov 2012, 9:33 AM
  3. MVC: Multiple instances of Controllers ?
    By dijksvi in forum Ext: Discussion
    Replies: 8
    Last Post: 19 Jul 2012, 6:36 AM
  4. Replies: 2
    Last Post: 14 May 2012, 9:21 AM
  5. Replies: 1
    Last Post: 1 Mar 2012, 4:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •