Skip to content

Commit

Permalink
Fix autocomplete unique id
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 3, 2024
1 parent 86c4691 commit 9c121b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions View/Elements/ActAsPeopleAutocomplete.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
}
});
Expand Down
11 changes: 7 additions & 4 deletions webroot/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ 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) {
const input = $(this.$el).find(`#${this.toKebabCase(this.action)}-input`);
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',
Expand All @@ -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');
}
Expand Down Expand Up @@ -99,7 +102,7 @@ export default {
})
},
template: /*html*/`
<div id="grouper-search-container" class="input-group">
<div :id="autcompleteId" class="input-group">
<div v-if="preInfo != ''" class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">
<span v-html="preInfo"></span>
Expand Down

0 comments on commit 9c121b4

Please sign in to comment.