shentao / vue-multiselect

Universal select/multiselect/tagging component for Vue.js
https://vue-multiselect.js.org/
MIT License
6.66k stars 991 forks source link

asynchronous select not works properly #1220

Open ShahrinNasrin92 opened 4 years ago

ShahrinNasrin92 commented 4 years ago

I am trying to do Asynchronous select with tag. While I'm selecting a value from dropdown list with keyword search api, it selects the wrong value. Can't get any proper solution.

Here is a part of my vue file: <Multiselect v-model="value" label="text" track-by="value" placeholder="Enter multiple email addresses, separated by a comma" :options="receiver_email" :taggable="true" @tag="addTag" :multiple="true" @search-change="getContacts">

Js file:

methods: { addTag (newTag) { const tag = { text: newTag, value: newTag.substring(0, 2) + Math.floor((Math.random() * 10000000)) } this.receiver_email.push(tag) this.value.push(tag) }, getContacts: function (q) { this.$store.dispatch('auth/setLoadingShow', false); this.contacts = [] let params = {} params['q'] = q params['limit'] = 10 this.$http_service.get("/auth-api/users/contacts",{params}) .then(response => { this.receiver_email=[]; this.response_data = response.data; this.contacts= this.response_data._embedded.userList; for(let key in this.contacts) { this.receiver_email.push({ text:this.contacts[key]['email'], value:key }) } }) .catch(function (error) { console.log(error.response); }) }, }

akki-jat commented 1 year ago

@ShahrinNasrin92 Please provide reproducible link