KazanExpress / vue-simple-suggest

Feature-rich autocomplete component for Vue.js
https://kazanexpress.github.io/vue-simple-suggest/
MIT License
461 stars 74 forks source link

How to get value-attribute in v-model? #307

Open lalits2002 opened 4 years ago

lalits2002 commented 4 years ago

I'm submitting a ...

What is the current behavior?

How can we access id in v-model. I am getting display value in my model variable. Please help???

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

How are you importing Vue-simple-suggest?

Using the script tag.

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

xlcrr commented 4 years ago

Can you share some code? If your v-model is an object, you should replace v-model with :value and update your state manually when you select something

bretthacker commented 2 years ago

I'm having this same issue, it's not clear at all. I'm returning { "id": "<guid>", "fullName":"Joe Blow" } My HTML looks like this: `<vue-simple-suggest v-model="assignedUserId" value-attribute="id" display-attribute="fullName" :debounce="200" :list="searchList">

My data component looks like this (snipped for brevity): data: { assignedUserId: null } `

I'm assigning v-model to a model where I'm expecting the value of assignedUserId to be the guid above, while the text component displays Joe Blow on the screen. It doesn't do this. I have no idea how to retrieve the value-component and as far as I can tell, it doesn't do anything at all. Please advise. I'm also using the script tag with the umd script.