-
27 Sep 2012 3:41 AM #1
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:
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.Code:Ext.application({ name: 'MyApp', appFolder: 'Scripts/App', launch: function () { alert(MyApp); } });
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?
-
27 Sep 2012 5:34 AM #2
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); ... } })
-
5 Oct 2012 2:47 AM #3
-
7 Nov 2012 10:23 PM #4
On 4.1.1a it is created, but MyApp.getApplication() method does not exist.
Why ?Using Ext with cachefly
Working on LAMPExt
-
7 Nov 2012 11:45 PM #5
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" } });


Reply With Quote