Reputation: 11
How do I clear the cache item list for auto complete ? I am using the cache-items flag. Once The user has the results for the current query and want to try a new list, I need the current items to be cleared.
I have "cache-items" on so the user can see all his selections before submitting.
<v-autocomplete v-if="showautocomplete" v-model="autocomplete_model"
:items="items" :loading="isLoading" autofocus
:search-input.sync="autocomplete_search" chips clearable hide-selected cache-items>
Upvotes: 1
Views: 2414
Reputation: 21
I don't know if you still need this but I think I've found an answer here: https://github.com/vuetifyjs/vuetify/issues/11365 from bka9.
You can add a ref on your v-autocomplete and change the cachedItems through the $refs. I'm not sure when you would have to trigger the method but that's all that's missing.
<template>
<v-autocomplete ref="autocomplete" cache-items ... />
</template>
<script>
methods: {
clearCachedItems() {
this.$refs.autocomplete.cachedItems = [];
},
},
</script>
Upvotes: 2