我有以下功能
function draw(i, arrayIdColetor, callback) {
var query = new $kinvey.Query();
query.equalTo('idColetor', arrayIdColetor[i]);
var promise = $kinvey.DataStore.find('myDatabase', query);
var latLong = promise.then(function(response) {
coordenadas = [];
for(var j = response.length - 1; j >= 0 ; j--) {
coordenadas.push( {lat: response[j].lat, lng: response[j].lng});
}
return coordenadas;
});
latLong.then(function(coordenadas) {
$kinvey.poly[i] = new google.maps.Polyline({ path: coordenadas, ... });
$kinvey.poly[i].setMap($kinvey.map); });
callback();
}
该函数由以下函数调用:
function callFor(j, arrayIdColetor) {
if (j < arrayIdColetor.length){
draw(j, arrayIdColetor, function() {
callFor(j + 1, arrayIdColetor)
});
}
}
函数 callFor 需要几秒钟才能执行,我希望在 callFor 函数运行时禁用所有界面按钮。我应该怎么解决?
还有一个问题,我希望另一个函数始终在 callFor 函数完成后运行。
感谢您的帮助。
最佳答案
也许你可以试试这个?我真的不明白为什么你要使用递归,因为你没有做任何建议使用递归的事情,而这只会让你希望的行为变得复杂。
function callFor(j, arrayIdColetor) {
//disable buttons
for (i = j; i < arrayIdColetor; i++) {
draw(i, arrayIdColetor, function(){});
}
//enable buttons
}
关于javascript - 回调后如何禁用界面中的所有按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34434421/