Closed 37Rb closed 3 years ago
@37Rb can you provide a codesandbox demonstrating the issue? example CS: https://codesandbox.io/s/vueautosuggest-api-fetching-57d4e
I figured out a way around it by looking at the multiple instances example in the storybook. I added a selected function and passed in the v-for index so I could set the model manually. Not sure if it's supposed to automatically bind but this seems to work fine.
<ul class="postings">
<li v-for="(posting, index) in transaction.postings" :key="posting.id">
<VueAutosuggest v-model="posting.account"
:suggestions="filterAccounts(posting.account)"
:input-props="{id:'p'+index+'__input', class:'p-account', placeholder:'account'}"
@selected="(suggestion) => accountSelected(index, suggestion.item)">
<template slot-scope="{suggestion}">
<span>{{ suggestion.item }}</span>
</template>
</VueAutosuggest>
</li>
</ul>
vue-autosuggest
version: 2.2.0node
version: 16.1.0npm
(oryarn
) version: 7.11.2I'm using vue-autosuggest in a dynamic list, list items are added and removed at runtime. Everything seems to work fine except the selected suggestions are not being stored in transaction.postings[i].account. Instead, when I read from transaction.postings[i].account I get back whatever was typed into the input element.
Instead of the suggestion value (dogs and cats) that's showing in the input, transaction.postings[i].account contains exactly what I typed (dog). I have also tried using :get-suggestion-value and @selected to no avail but I don't think they are necessary for this use case.
How do I get the suggestion value to show up in the vue model?