Hybrid View

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2012
    Posts
    32
    Vote Rating
    0
    metas is on a distinguished road

      0  

    Question Cannot add additional function for init() function in a controller

    Cannot add additional function for init() function in a controller


    init: function() {

    this.control({
    ...
    //Designer2.x support coding here now.
    });
    //But cannot support coding here!
    }

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,445
    Vote Rating
    129
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Go to Code View, in the dropdown at the top left change the controller to init.

    Code that you add here will be placed directly after this.control() in the init block.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Olney, MD
    Posts
    1,953
    Vote Rating
    65
    Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice

      0  

    Default


    However note that you won't have access to getters and setters in init. 90% of the "initialization code" should be placed in the launch function of your controllers
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team

  4. #4
    Ext JS Premium Member
    Join Date
    Jan 2012
    Posts
    32
    Vote Rating
    0
    metas is on a distinguished road

      0  

    Default Should it be fired when the controller is dynamically loaded

    Should it be fired when the controller is dynamically loaded


    Thanks Phil.Strong

    "onLaunch()" in controllers like below 'MonitoringController' will not be fired.

    Code:
    if (selections && selections.length) {
        var monitorCtrl = this.getController('MonitoringController'),
            tab = Ext.widget(
            'monitoringTab', 
            {closable: true, title: 'Monitoring - ' + selections[0].data.factory}
            );
        monitorCtrl.init();
        this.getTabPanel().setActiveTab(this.getTabPanel().add(tab));
    }
    Getter for ref and store works in init().

  5. #5
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Olney, MD
    Posts
    1,953
    Vote Rating
    65
    Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice

      0  

    Default


    what works and doesn't work depends on version of ST 2 your using. The latest has a launch function (not onLaunch) and ... ref getters and setters aren't ready in init

    Code:
    launch: function() {
    
    }
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team

  6. #6
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Olney, MD
    Posts
    1,953
    Vote Rating
    65
    Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice

      0  

    Default


    ExtJS does allow for you to use init function along with controller reference getters/setters. Just to be clear.

    Also onLaunch is the correct "launch" function and needs to be added as a basicFunction
    fn: 'onLaunch'
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team