-
4 Jan 2012 1:05 PM #1
Answered: Create a config file
Answered: Create a config file
Hi guys,
can some one tell me how to create a config file so that i could use it across the application.
In JavaScript i would create a file called config and
and then call mapconfig.generalSetting to get the general setting values in my application.Code:ar mapserviceUrl1 = "http://204.94.80.163/ArcGIS/rest/services/"; var mapserviceUrl = "http://map1-2.lan.511.org/ArcGIS/rest/services/"; //var localImageDir = mapImageDirectory; function mapConfig() { }; var mapconfig = new mapConfig(); //mapConfig.prototype.LocalImageDir = localImageDir; mapConfig.prototype.generalSettings = { defaultZoomLevel: 2, defaultQueryTolerancePixels:2 } mapConfig.prototype.generalSettings = { defaultZoomLevel: 2, defaultQueryTolerancePixels: 2 }; mapConfig.prototype.spatialReference = { parking: new esri.SpatialReference({ wkid: 4269 }) };
How can i perform the same in sencha touch 2
Regards,
Paw
-
Best Answer Posted by mitchellsimoens
You can still create a config file and include it as a <script> tag in your index.html file. The namespace won't be setup if you are wanting to use a namespace like in the MVC. If you are using MVC, I personally create a singleton that I require first...
Above your Ext.application call you can then use Ext.require to load this file:Code:Ext.define('MyApp.Config', { singleton : true, config : { urls : { users : 'users/get.php' } } });
Within your application classes you can get a url via:Code:Ext.Loader.setPath('MyApp', 'app'); Ext.require([ 'MyApp.Config' ]);
Code:MyApp.Config.getUrls().users
-
5 Jan 2012 6:19 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
You can still create a config file and include it as a <script> tag in your index.html file. The namespace won't be setup if you are wanting to use a namespace like in the MVC. If you are using MVC, I personally create a singleton that I require first...
Above your Ext.application call you can then use Ext.require to load this file:Code:Ext.define('MyApp.Config', { singleton : true, config : { urls : { users : 'users/get.php' } } });
Within your application classes you can get a url via:Code:Ext.Loader.setPath('MyApp', 'app'); Ext.require([ 'MyApp.Config' ]);
Code:MyApp.Config.getUrls().users
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
5 Jan 2012 10:36 AM #3
This is what i was looking for. Thanks.
I was trying to do some thing like this which worked but was not sure.
Thanks once againCode:Ext.define('Utils.parkingMapConfig', { statics: { generalSettings: { defaultZoomLevel: 2, defaultQueryTolerancePixels: 2 }, spatialReference: { parking: new esri.SpatialReference({ wkid: 4269 }) }, mapService: { baseMapTileSTANDARD: "http://204.94.80.163/ArcGIS/rest/services/MMTPBaseMap/MapServer", blockFace: "http://map2-2.lan.511.org/ArcGIS/rest/services/UPPParking/MapServer" }, streetParkingLayers: { Zones: [6, 8, 10], BlockFaces: [1, 3, 5], Both: [1, 3, 5, 6, 8, 10] }, dynamicLayerList: [ "blockFace,http://map2-2.lan.511.org/ArcGIS/rest/services/UPPParking/MapServer" ], baseLayerList: [ "baseMapTileSTANDARD,http://204.94.80.163/ArcGIS/rest/services/MMTPBaseMap/MapServer" ], blockFaceZoomLevelQueryTolerance: { 0: 3, 1: 3, 2: 4, 3: 4, 4: 5, 5: 8, 6: 9, 7: 15, 8: 10, 9: 10, 10: 10, 11: 10 } }, constructor: function (config) { this.initConfig(config); // the 'self' property of an instance refers to its class this.self; } });
-
24 Feb 2013 1:07 PM #4
set users
set users
Hi!
How can I set urls.users in your example?
doesn't work of course..Code:MyApp.Config.getUrls().users
Sorry for kidnapping your thread
-
25 Feb 2013 5:22 AM #5
Take a look at the Anthologia app example....
Take a look at the Anthologia app example....
For a working example take a look at the Anthologia magazine app example in examples and showcases part of the forum
:-)
-
28 Feb 2013 10:38 PM #6
Thanks! The advice to look at the showcases was really good. In the Ux.locale.Manager showcase I found the solution to my problem!


Reply With Quote