Results 1 to 4 of 4

Thread: How to call one controller function from another one?

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    99
    Vote Rating
    4
      0  

    Default How to call one controller function from another one?

    Hello,

    I was wondering how I can call a controller's function from within another one of the controller's functions? For instance, I have my MainController which has functions exampleOne and exampleTwo, in the code for exampleTwo:

    Code:
    exampleTwo: function () {
    
    //how do I call exampleOne() here?
    
    }
    I'm guessing I need to reference the controller and then call it's function, I just don't know how, please help.

  2. #2
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,425
    Answers
    20
    Vote Rating
    685
      -2  

    Default

    There's a ton of info here.

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    99
    Vote Rating
    4
      0  

    Default

    Hi Les,

    I can't seem to get this to work, whenever I call this.getController() from within one of it's actions/functions, for example:

    Code:
    var option = this.getController('mainController');
    I get the error: 'object is not a function' VM3195:3

    Which looks like this:

    Code:
    (function(c,a
    /**/) {
    return new c(a[0])
    })

  4. #4
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    2,425
    Answers
    20
    Vote Rating
    685
      -2  

    Default

    You need to use the name of the controller instead of id.

    This is a bug in Ext JS.

Posting Permissions

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