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

    init: function() {

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

  2. #2
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,485
    Vote Rating
    135
    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

  3. #3
    Sencha User 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

  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

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

  6. #6
    Sencha User 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

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

      0  

    Default My fault, should be "launch()"

    Hi Pil Strong,

    launch() in a controller could not be fired automatically when the controller is loaded in this way:
    Code:
    AnotherController.getController("TheController");
    The way to fire launch() is to invoke it directly like below.
    Code:
    AnotherController.getController("TheController").launch();
    Is it right?
    As my understanding, your point is launch() should be more safe than init() because getter and setter are prepared in launch() but maybe not in init().

    Thanks,
    Metas

  8. #8
    Sencha User 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

    You shouldn't need to call launch. Simply include the controller name in your Ext.Application controllers property like so:

    Code:
    Ext.application({
        name: 'MyApp',
    
        controllers: [
            'MyController'
        ],
    
        launch: function() {
    
        }
    });
    where controller is:
    MyApp.controller.MyController
    Phil Strong
    @philstrong

  9. #9
    Sencha User
    Join Date
    Apr 2012
    Posts
    3
    Vote Rating
    0
    dhana@urjita.co.in is on a distinguished road

      0  

    Default Unable to Edit Launch function

    Hi
    I am using Sencha Architect Version: 2.2.2 Build: 991,
    and I am trying change the Startup application in the Launch Function and not allowed
    I also have created (added) lauch function which shows empty initially and when code is added get appended with existing code

    Any one found this and any resolution for this problem

    Thanks
    Dhana

  10. #10
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,485
    Vote Rating
    135
    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

    Quote Originally Posted by dhana@urjita.co.in View Post
    I also have created (added) lauch function which shows empty initially and when code is added get appended with existing code

    Any one found this and any resolution for this problem
    This is how it works. If you don't want architect to create the initial view and want to create your own launch code without any help from architect; right click on your initial view and say unmark as initial view.

    Whatever is in your launch fn will be what is run with no additions.
    Aaron Conran
    @aconran