site: bind search component open to items.length
This commit is contained in:
parent
cc25efc5f4
commit
bf21610576
2 changed files with 4 additions and 5 deletions
|
@ -25,7 +25,7 @@ document.addEventListener('alpine:init', () => {
|
|||
return;
|
||||
if (currentWord === this.currentWord) {
|
||||
/* Show previous items, if any. */
|
||||
this.open = true;
|
||||
this.open = this.items.length > 0;
|
||||
return;
|
||||
}
|
||||
this.currentWord = currentWord;
|
||||
|
@ -35,12 +35,13 @@ document.addEventListener('alpine:init', () => {
|
|||
|
||||
if (!response.ok) {
|
||||
this.items = [];
|
||||
this.open = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.activeItem = null;
|
||||
this.items = await response.json();
|
||||
this.open = true;
|
||||
this.open = this.items.length > 0;
|
||||
},
|
||||
|
||||
async fetchSuggestionsOnInput(evt) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue