1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    21
    Vote Rating
    1
    DracisFL is on a distinguished road

      0  

    Default Multiple Controllers

    Multiple Controllers


    Hi All, I need some conceptual direction on this please.

    layout.png
    I have two controllers.. and all code/Views are fine independent of one another and function as I expect. Now suppose I create an event listener in controller 2 where I want it to perform some function in controller 1 or reference some view associated with controller 1.. I cannot seem to grab a reference for the life of me !! Is this even possible ? I would imagine it should be.. Help !! Thanks in advance.

    p.s. I did try this.getController() and this.getView() - but did not have any luck with that

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    350
    Vote Rating
    1
    bharatn is on a distinguished road

      0  

    Default


    From controller2 use this.getApplication().getController('controller1') and then if you have references(refs) setup in controller1 you should be able to get reference to a view
    Bharat Nagwani
    Sencha Designer Development Team

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    21
    Vote Rating
    1
    DracisFL is on a distinguished road

      0  

    Default


    Thanks bharatn,

    I'm getting this error

    Uncaught TypeError: Object [object Object] has no method 'getApplication'

    so I tried

    this.MyApp.getController('shipControl');

    since MyApp is the name of my Application..

    Uncaught TypeError: Cannot call method 'getController' of undefined

    and I tried several other variations..

    I'll look into it more tomorrow when I have time, probably something simple I am missing.

    Thanks again

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,358
    Vote Rating
    128
    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


    getApplication() only works in Touch. Use .application in Ext.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    21
    Vote Rating
    1
    DracisFL is on a distinguished road

      0  

    Default


    Thanks aconran, that got me the reference to the other Controller

    var test = this.application.getController('shipControl');
    test.init();


    From here I was able to call a method in the other controller..

    Appreciate the help..

Thread Participants: 2