当其中一个函数涉及等待弹出窗口时,如何让一系列函数按顺序执行?
在下面的authBegin
函数中,我弹出一个窗口,authBegin
完成后返回函数。
但是链接当然不会等待。我怎样才能让它等到窗口回来?
am.authUnlessCurrent().authBegin().collectData();
var authModule=function(){
this.authUnlessCurrent=function(){
alert("checks auth");
};
this.authBegin=function(){
window.oauth_success = function(userInfo) {
popupWin.close();
return this;
}
window.oauth_failure = function() {
popupWin.close();
return true;
}
popupWin = window.open('/auth/twitter');
};
this.collectData=function(){
alert("collect data");
return this;
};
}