Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit 8d2afc6

Browse files
authored
Merge pull request #427 from elkami12/issue-426
Fix for issue #426 (Not found" when an external request is cancelled)
2 parents fc6028e + f5be208 commit 8d2afc6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

angucomplete-alt.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
var responseFormatter;
7474
var validState = null;
7575
var httpCanceller = null;
76+
var httpCallInProgress = false;
7677
var dd = elem[0].querySelector('.angucomplete-dropdown');
7778
var isScrollOn = false;
7879
var mousedownOn = null;
@@ -440,7 +441,7 @@
440441
}
441442

442443
function httpErrorCallback(errorRes, status, headers, config) {
443-
scope.searching = false;
444+
scope.searching = httpCallInProgress;
444445

445446
// normalize return obejct from promise
446447
if (!status && !headers && !config) {
@@ -478,9 +479,11 @@
478479
cancelHttpRequest();
479480
httpCanceller = $q.defer();
480481
params.timeout = httpCanceller.promise;
482+
httpCallInProgress = true;
481483
$http.get(url, params)
482484
.success(httpSuccessCallbackGen(str))
483-
.error(httpErrorCallback);
485+
.error(httpErrorCallback)
486+
.finally(function(){httpCallInProgress=false;});
484487
}
485488

486489
function getRemoteResultsWithCustomHandler(str) {

0 commit comments

Comments
 (0)