1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    -13
    Dhugal can only hope to improve

      0  

    Default Unanswered: Ext.application does not create App object/namespace

    Unanswered: Ext.application does not create App object/namespace


    Hi All,

    I am creating a new project using Ext 4.1 and attempting to use the MVC architecture however I have hit an issue in that the behaviour I am getting does not match the documentation.

    Specifically I am using the following code:

    Code:
    Ext.application({
        name: 'MyApp',
        appFolder: 'Scripts/App',
        launch: function () {
            alert(MyApp);
        }
    });
    The code throws an error on the alert call because MyApp has not been created. I have also tried this outside of the launch function (in Chromes console) and the object has not been created after the Ext.application has finished initialising.

    What I am expecting is the call to Ext.application to create a global variable, in this case named "MyApp", as detailed in the documentation here:

    http://docs.sencha.com/ext-js/4-0/#!...pp.Application

    Which when referring to this method states:

    This does several things. First it creates a global variable called 'MyApp' - all of your Application's classes (such as its Models, Views and Controllers) will reside under this single namespace, which drastically lowers the chances of colliding global variables.

    So I should subsequently be able to use code as follows to address the application elsewhere:

    MyApp.getApplication()

    So right now I am stuck because I don't have any way to address the application object.

    Can anyone point out what's going on here please?

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    It seems that Ext.application will only create application namespace if it has to load at least one application class, such as a controller (by using controllers config), viewport (with autoCreateViewport set to true), or a normal class with requires config.
    My solution is explicitly create application namespace:
    Code:
    Ext.application({
        name: 'App',
        ...
        launch: function(){
            var me = this;
            Ext.namespace(me.name);
            ...
        }
    })

  3. #3
    Sencha User
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    -13
    Dhugal can only hope to improve

      0  

    Default


    Great - thanks for the response vietits.

  4. #4
    Sencha User mysticav's Avatar
    Join Date
    Mar 2007
    Location
    Mexico
    Posts
    474
    Answers
    2
    Vote Rating
    5
    mysticav is on a distinguished road

      0  

    Default


    On 4.1.1a it is created, but MyApp.getApplication() method does not exist.

    Why ?
    Using Ext with cachefly
    Working on LAMPExt

  5. #5
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    No, with 4.1.1a, the situtation is still the same. It won't create application namespace if it won't have to load any application class.
    Code:
    Ext.application({
        name: 'App',
        appFolder: 'app',
        launch: function() {
            console.log(App); // this will cause error "Uncaught ReferenceError: App is not defined"
        }
    });

Thread Participants: 2

Tags for this Thread

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