PDA

View Full Version : Variable not accessible out side store load



prakashkadakol
28 Jun 2012, 11:13 PM
Hi

I am using two flags multiflag and brodflag initially set false,Based on some conditions am setting true inside store load but problem am facing is inside store load flag set to true but outside store load shows false tried with this.multiflag and this.brodflag but no use still flag set to false,any suggestions or ideas for this ???


function action(){
multiflag=false;
brodflag=false;
/*
this.multiflag=false;
this.brodflag=false;
*/
this.getTablePanel().store.on('load', function(store, records, options) {
//Based on Some condition
multiflag=true;
brodflag=true;


});
console.log(multiflag+"---------"+brodflag);


});

skirtle
28 Jun 2012, 11:33 PM
Please use [CODE] tags when posting code.

There are two problems you may be facing.

Firstly, the store load is asynchronous so if you set flags in the listeners they won't be updated until after the server has returned.

Secondly, if you try to set flags on this you'll need to be careful of your scope on the listener. Unless you ensure that this is what you expect it to be you'll be setting the flags on the wrong object.