Skip to content

Commit d7b487c

Browse files
author
Tomas Kirda
committed
Abort ajax request on blur, fixes devbridge#357
1 parent 08c284c commit d7b487c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/jquery.autocomplete.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@
217217
onBlur: function () {
218218
this.enableKillerFn();
219219
},
220+
221+
abortAjax: function () {
222+
var that = this;
223+
if (that.currentRequest) {
224+
that.currentRequest.abort();
225+
that.currentRequest = null;
226+
}
227+
},
220228

221229
setOptions: function (suppliedOptions) {
222230
var that = this,
@@ -256,9 +264,7 @@
256264
var that = this;
257265
that.disabled = true;
258266
clearInterval(that.onChangeInterval);
259-
if (that.currentRequest) {
260-
that.currentRequest.abort();
261-
}
267+
that.abortAjax();
262268
},
263269

264270
enable: function () {
@@ -573,9 +579,7 @@
573579
that.suggest();
574580
options.onSearchComplete.call(that.element, q, response.suggestions);
575581
} else if (!that.isBadQuery(q)) {
576-
if (that.currentRequest) {
577-
that.currentRequest.abort();
578-
}
582+
that.abortAjax();
579583

580584
ajaxSettings = {
581585
url: serviceUrl,

0 commit comments

Comments
 (0)