Reputation: 13
I'm creating an application that has a high dependency on geographic location. I have variables 'GeoApp.app.geoLat' and GeoApp.app.geoLong' in app.js that are set with the geo coordinates.
If I console.out within any view, I have no problem accessing and outputing the values. Within a store, the values are empty as if it doesn't have access or perhaps variables haven't been defined or exist.
What is the best practice achieve what I am trying to do?
Ext.define('GeoApp.store.Places', {
extend:'Ext.data.Store',
config: {
model:'GeoApp.model.Place',
autoLoad:'true',
proxy: {
type:'ajax',
url:'googleapiurl/json?location=' + GeoApp.app.geoLat + ','+ GeoApp.app.geoLong + '&radius=500...',
reader: {
type:'json',
rootProperty:'results'
}
}*/
}
})
Upvotes: 1
Views: 2450
Reputation: 690
What you can do is set the proxy url before you load the store. Therefor you have to set autoLoad
to false
. You could use the code below in, for example, the show()
function of your view component.
show: function(component, options){
var store = Ext.getStore('Places');
store.setProxy({
url:'googleapiurl/json?location=' + GeoApp.app.geoLat + ','+ GeoApp.app.geoLong + '&radius=500...',
});
store.load();
}
Good luck!
Upvotes: 0
Reputation: 12949
That's because your store is created when you app launches and so is your url string. Therefore, GeoApp.app.geoLat
and GeoApp.app.geoLong
being null or undefined when you launch your app, they don't appear in your url.
What I would do is set the url to googleapiurl/json?radiu=500...
and then add the location
parameter as an extraParam
of the proxy like so:
Ext.getStore('Places').getProxy().setExtraParams({
location: GeoApp.app.geoLat + ',' + GeoApp.app.geoLong
});
Hope this helped
Upvotes: 1