问题
I have a window include many combo with default autoload = false. I want to wait all combo in my window is loaded after that i will show window like
var arrCombos = window.query('combo');
Ext.each(arrCombos, function(combo){
combo.getStore().load(); // load
});
WaitForFunction(arrCombos); // wait for loading done
window.show(); // show my window
Here is my WaitForFunction
function WaitForFunction(arrCombos) {
var all = 1;
Ext.each(arrCombos, function(combo){
if (combo.store.isLoading()) {
all = 0;
}
});
if (all == 0){
setTimeout(WaitForFunction(arrCombos), 100);
}
}
But fail, that said too much recursion
How can i do that thank.
回答1:
Quick and dirty but something like this should work:
var arrCombos = window.query('combo'),
storeCt = 0;
function checkState() {
if(--storeCt == 0)
window.show();
}
Ext.each(arrCombos, function (combo) {
var store = combo.getStore();
storeCt++;
store.on('load', checkState, this, {single: true})
store.load(); // load
});
来源:https://stackoverflow.com/questions/17942315/extjs-4-1-how-to-wait-all-store-in-combo-is-loaded