Would you please help me take a look codes below? Why I'm unable to get the value outside of callback?
Any comments would be appreciated.
var i = 0;
var myModulesName = [];
me.store.load({callback: function(){
me.store.data.each(function(records) {
if(records.raw.hasLeaf === true){
//Ext.Function.defer(function() {
myModulesName[i] = records.raw.name;
console.log('this is constructor App.js inside storeload '+myModulesName[i]);
//}, 100, me);
++i;
}
});
}
});
//empty here.
console.log('this is constructor outside of load '+myModulesName);
This piece of codes located in a constructor function and I have another function called init() which will be fired after constructor. And the codes below is at the end of my constructor.
if (Ext.isReady) {
Ext.Function.defer(me.init, 10, me);
} else {
Ext.onReady(me.init, me);
}
I just moved this part into load() and at the end of 'each' part and it worked! I'm able to get modulesName now.