Reputation: 1277
I've tried to make an extjs global variable class like so:
Ext.define('ccc.global.GlobalVariables', {
singleton: true,
username: 'hi user',
password: '',
clientID: '',
token: ''
});
Then in a controller I try to change the variable like so:
ccc.global.GlobalVariables.username = loginData.username;
Now I am trying to access those variables in a different model proxy and it keeps coming back the original value of 'hi user'
.
proxy: {
type: 'ajax',
extraParams: {
'username': ccc.global.GlobalVariables.username
},
Anyone see what I am doing wrong?
Upvotes: 0
Views: 193
Reputation: 20224
When a variable is used in the proxy definition, the variable content is set into the proxy at definition time, not at instantiation and especially not at use time. It won't update automatically.
This is why, at least for components, there is bind
property which explicitly tells the component which config to bind to an external source, such that it is automatically updated when the source is updated.
IIRC a proxy does not support the bindable mixin, so you will have to set the extraParam manually before each sync/load/... operation:
store.getProxy().setExtraParam("username",ccc.global.GlobalVariables.username);
store.load()
Upvotes: 5