Hybrid View

  1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    84
    Vote Rating
    0
    nofx is on a distinguished road

      0  

    Default global variables

    global variables


    I'm using Designer 2 to create my sencha 2 app. But now i'm in the need of using a global variable(s).
    Normally i would just create another .js file called globals.js in which i put some global variables, like a url to a wsdl and include that into my index.hmtl.

    But i was wondering if Designer 2 offers some kind of abillity to add global variables which can be used throughout my application.

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,182
    Vote Rating
    119
    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 would recommend against using truly global variables but I would recommend using application specific variables.

    One way you could achieve this would be to go into your Application's launch method and create a global property which can be accessed throughout all of your source.

    For example:
    Code:
    MyApp.globals = {
       key: 123,
       key2: 'abc'
    };
    The touch20/yql.xda example does something similar. You can download the sample projects from this link:
    http://www.sencha.com/forum/showthre...Download-links
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Jun 2009
    Posts
    84
    Vote Rating
    0
    nofx is on a distinguished road

      0  

    Default


    Quote Originally Posted by aconran View Post
    I would recommend against using truly global variables but I would recommend using application specific variables.

    One way you could achieve this would be to go into your Application's launch method and create a global property which can be accessed throughout all of your source.

    For example:
    Code:
    MyApp.globals = {
       key: 123,
       key2: 'abc'
    };
    The touch20/yql.xda example does something similar. You can download the sample projects from this link:
    http://www.sencha.com/forum/showthre...Download-links
    Thanks, thats working fine.

    I do have another problem though. I also need a few 'global' functions. I used to just add functions to my controller which i could just call like:

    myApp.controller.Main.backButton();

    But in the Designer tool i can only add functions based on events, like; keyUp, onItemTap etc. I can't even approach my controller anymore through "MyApp.controller.Main.backButton()" (that's how it is Ext.defined).

    But sometimes i just want to call a custom function. Any idea how i'm able to do that in the Designer tool? Couldn't find the answer for this in the examples.

  4. #4
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,264
    Vote Rating
    80
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    You can add "Basic Function" to Application, Controllers and containers.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  5. #5
    Sencha User
    Join Date
    Jun 2009
    Posts
    84
    Vote Rating
    0
    nofx is on a distinguished road

      0  

    Default


    I just added a basic function, but now i have a new problem. How do i call it?

    I created a controller, gave it an "userAlias" and the same "userClassName". Then i added a Basic Function to the controller with a function name.

    Now i also have a list of DIVs which i load inside a panel. These DIVs have an "onclick" event which i want to use to call my function.

    I tried to call the function like this:

    MyApp.controller.TestController.showTest();

    And even with the component query:
    Ext.ComponentQuery.query('TestController')[0].showTest();

    But both didn't work.. How should this be done from an "onclick" event??

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


    If you are within the same class, the syntax is this.showTest()
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  7. #7
    Sencha User
    Join Date
    Nov 2013
    Location
    Ottawa, ON
    Posts
    4
    Vote Rating
    0
    brunp is on a distinguished road

      0  

    Default


    Quote Originally Posted by aconran View Post
    I would recommend against using truly global variables but I would recommend using application specific variables.

    One way you could achieve this would be to go into your Application's launch method and create a global property which can be accessed throughout all of your source.

    For example:
    Code:
    MyApp.globals = {
       key: 123,
       key2: 'abc'
    };
    The touch20/yql.xda example does something similar. You can download the sample projects from this link:
    http://www.sencha.com/forum/showthre...Download-links
    How do you access these global properties from an event such as when you click a button? I think I added the parameters properly? I replaced "MyApp.globals", with the name of my application that I defined --> "<AppName>.globals", and when I try to access it in the js event function, I get an error saying that "<AppName>.globals does not exist.???

    Paul

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi