PDA

View Full Version : global variable not working with sencha build



mihaipocorschi
6 Aug 2012, 12:41 AM
I declare the global variable inside Ext.application like this


Ext.application({ name: 'mobuy',
...
baseURL = "http://test.com"

i use it in my stores like this

mobuy.app.baseURL
In debug code it works perfectly. But whenever i do
sencha app build testing i get this error

Uncaught TypeError: Cannot read property 'baseURL' of undefined

Have no idea what else to try. Not even declaring it outside everything in app.js works.

Bukurov Alex
7 Aug 2012, 8:43 PM
not only global variables, all variables which are used in component config

mihaipocorschi
8 Aug 2012, 1:03 AM
I dont really understand your question but anyway the only solution I found that works well with sencha build is declaring a utility function like mitchell recommended in another post:

app/util/Config.js



Ext.define('myapp.util.Config', {
singleton : true,


config : {


baseurl : 'http://localhost.com'
},


constructor : function(config) {
this.initConfig(config);
this.callParent([config]);
}
});


and then accessing it from the stores like:
myapp.util.Config.getBaseurl()