1. #1
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    104
    Vote Rating
    3
    gatherworks is on a distinguished road

      0  

    Default Calling Application Basic Functions

    Calling Application Basic Functions


    Hi,

    I have defined an Application Basic Function and added code to it. I see the code in the generated application config file.

    However, now I am stumped. How do I call this method. I have inspected the all the variables in the debugger and could not find a way to call that function.

    My app is named AdminApp.... tried AdminApp.method(); Ext.app.... does not have any reference to it.

    Please let me know what I am missing here.

    Thanks!

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    104
    Vote Rating
    3
    gatherworks is on a distinguished road

      0  

    Default


    I see the "MOVE" prefix on this post. Is that a good thing or a bad thing?

    Would it be possible to find out where things are moved to?

    (I figured out that it was moved to Help & Discussions instead of bugs where I posted it. But still wondering if the move tag could have told me that in the first place). Just some feedback for a future version.

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


    Move just denoted that it was a discussion topic, not a bug.

    Touch and Ext have slightly different syntaxes for invoking the method of an Application method since Touch has a newer MVC package. (You can assume that future versions of Ext will be closer to Touch).

    The following assumes we have adding a method named "myMethod" to our Application and we are using the default namespace of "MyApp". Change these to be appropriate to your application.

    In Touch:

    In controllers, you can access the application instance by invoking this.getApplication().
    Code:
    this.getApplication().myMethod();
    Touch stores a global reference to the application instance in MyApp.app.
    Code:
    MyApp.app.myMethod();
    In Ext:

    In controllers, you can access the application instance by the property this.application.
    Code:
    this.application.myMethod();
    Ext does not store a global reference to the application instance.

    Once you have a reference to the application instance you can invoke the method.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    104
    Vote Rating
    3
    gatherworks is on a distinguished road

      0  

    Default


    Thanks. I am using Ext and I am not inside a controller. Does that mean that I cannot access this function?

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


    I'd probably do MyApp.app = this; within Application launch. That way you can access it via the global MyApp.app.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  6. #6
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    104
    Vote Rating
    3
    gatherworks is on a distinguished road

      0  

    Default


    Thanks! That works great.

Thread Participants: 1