From 9c121b4adaf50c78b2d6181be5b183e368f6554b Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 3 Apr 2024 14:06:15 +0300 Subject: [PATCH] Fix autocomplete unique id --- View/Elements/ActAsPeopleAutocomplete.ctp | 3 +-- webroot/js/autocomplete.js | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/View/Elements/ActAsPeopleAutocomplete.ctp b/View/Elements/ActAsPeopleAutocomplete.ctp index 26a951a..46d5180 100644 --- a/View/Elements/ActAsPeopleAutocomplete.ctp +++ b/View/Elements/ActAsPeopleAutocomplete.ctp @@ -142,12 +142,11 @@ $suffix = Configure::read('debug') > 0 ? '?time=' . time() : ''; this.loading = false; return } - // generateFlash('Act As User Enabled', 'success'); this.rawData = await resp.json(); console.log(this.rawData) this.loading = false - window.location.reload(); // Force reload here + window.location.reload(); }, } }); diff --git a/webroot/js/autocomplete.js b/webroot/js/autocomplete.js index da566ce..50703f2 100644 --- a/webroot/js/autocomplete.js +++ b/webroot/js/autocomplete.js @@ -50,6 +50,9 @@ export default { // The minimum length that i start search is 3. So we only enable the button when // the input text value has at least three characters return this.activeBtn || (this.search.length < 3) + }, + autcompleteId() { + return `autocomplete-search-container-${this.action}` } }, mounted(el) { @@ -57,7 +60,7 @@ export default { this.url = `${this.api.find}?co=${this.api.co}&mode=${this.api.mode}&page=${this.page}&limit=${this.limit}` input.autocomplete({ source: ( request, response ) => { - $("#grouper-search-container .co-loading-mini").show(); + $(`#autocomplete-search-container-${this.action} .co-loading-mini`).show(); $.ajax({ url: this.url, type: 'GET', @@ -67,11 +70,11 @@ export default { term: request.term }, success: function (data) { - $("#grouper-search-container .co-loading-mini").hide(); + $(`#autocomplete-search-container-${this.action} .co-loading-mini`).hide(); response( data ); }, error: function(data) { - $("#grouper-search-container .co-loading-mini").hide(); + $(`#autocomplete-search-container-${this.action} .co-loading-mini`).hide(); console.log('Autocomplete ajax error:', data) generateFlash('Find action failed', 'error'); } @@ -99,7 +102,7 @@ export default { }) }, template: /*html*/` -
+