1
我有一個ExtJS
4.2.1 Controller
,我在1秒鐘後使用setTimeout的觸發功能:的ExtJS的setTimeout循環功能無法正常工作(失去範圍)Ext.bind
onPrint: function() {
var me = this;
// start some stuff here...
// end some stuff here...
// wait 1 second and call checkDownloadComplete function
setTimeout(me.checkDownloadComplete, 1000);
},
checkDownloadComplete: function() {
var me = this;
// validate stuff here...
if (something == "true") {
return;
}
// first approach but didn't work (maybe because the scope)
setTimeout(me.checkDownloadComplete, 1000);
// sencond approach but didn't work
Ext.bind(function() {
setTimeout(checkDownloadComplete, 1000)
}, me)
},
我的第一次嘗試是使用:
setTimeout(me.checkDownloadComplete,1000);
但這並沒有工作
我的第二次嘗試是發表評論的最後一行,並使用Ext.bind:
Ext.bind(funciton(){setTimeout(checkDownloadComplete,1000)},me);
任何線索我在做什麼錯?因爲這些工作都不需要自己調用函數。
感謝
UPDATE:
我也試試這個,但沒有成功:
setTimeout(Ext.bind(checkDownloadComplete,me), 1000);
你應該嘗試的setTimeout(函數(){me.checkDownloadComplete.call(我) },1000) – Dart