我需要弄清楚如何同步调用这个函数。
fetchData: function(recs){
store = Ext.getStore('OutOfBalanceList');
store.reload({
params: {
startDate: searchForm.startDate,
endDate: searchForm.endDate,
cusip: searchForm.cusip,
account: searchForm.account
},
callback: function (records, options, success) {
recs = records.length;
return recs;
}
});
},
我很欣赏所有关于异步的说教,但在这种情况下我必须使用同步调用,因为当返回的数据为空时,我必须使用不同的参数再次回调。目前,这最终成为一个无限循环,因为“recs”在外部没有改变!
非常感谢
最佳答案
不要尝试使其同步。在回调方法中执行“使用不同参数再次调用”。像这样的事情:
fetchData: function(recs) {
var me = this;
store = Ext.getStore('OutOfBalanceList');
store.reload({
params: {
startDate: searchForm.startDate,
endDate: searchForm.endDate,
cusip: searchForm.cusip,
account: searchForm.account
},
callback: function (records, options, success) {
if (records.length == 0) {
me.fetchDataWithDifferentParameters();
}
}
});
}
如果您要使用 JavaScript 框架并调用外部数据源,那么学习如何使用回调非常重要。
关于javascript - EXT js 如何同步调用Store,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34436377/