From 34577fd8cef0f9a5ed808780e4b7176f3110dbc3 Mon Sep 17 00:00:00 2001 From: Daniel Maier Date: Mon, 5 Feb 2018 14:25:08 +0100 Subject: [PATCH] [task] fix for issue #53 add local variable `this.autosuggestRequest` in which the actual / last GET-Request is stored. before sending a new GET-Request the old one is being cancelled if it exists. --- main/src/view/frontend/web/js/form-mini.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main/src/view/frontend/web/js/form-mini.js b/main/src/view/frontend/web/js/form-mini.js index d3de8c4..8600e29 100755 --- a/main/src/view/frontend/web/js/form-mini.js +++ b/main/src/view/frontend/web/js/form-mini.js @@ -38,6 +38,7 @@ define([ indexList: null, selected: null }; + this.autosuggestRequest = null; this.autoComplete = $(this.options.destinationSelector); this.searchForm = $(this.options.formSelector); this.submitBtn = this.searchForm.find(this.options.submitBtn)[0]; @@ -255,7 +256,11 @@ define([ this.submitBtn.disabled = isEmpty(value); if (value.length >= parseInt(this.options.minSearchLength, 10)) { - $.get(this.options.url, {q: value}, $.proxy(function (data) { + if (this.autosuggestRequest != null) { + this.autosuggestRequest.abort(); + } + + this.autosuggestRequest = $.get(this.options.url, {q: value}, $.proxy(function (data) { if (value != searchField.val()) { // Looked up keyword doesn't match current keyword any more - don't overwrite. return;