vue-autosuggest icon indicating copy to clipboard operation
vue-autosuggest copied to clipboard

Initial selected object

Open p0g opened this issue 5 years ago • 5 comments

  • vue-autosuggest version: 2.2.0

hi.

How to preselect an object value?

Using the v-model, is only setting the "userinput", but not the selected-value (and it only accept Strings)

See the forked sandbox where i try to set Gandalf at the inital, selected object, without any user-interaction. https://codesandbox.io/s/vueautosuggest-20-base-forked-cgy1s?file=/App.vue:2857-3206

This function is relevant for an project where i store the selected object in localstorage, to restore later without bother the user every time.

p0g avatar Nov 05 '20 18:11 p0g

Were you able to find a solution for this?

jesseschutt avatar Mar 24 '21 23:03 jesseschutt

Were you able to find a solution for this?

No sorry, and i dont use this component anymore (to outdated)

p0g avatar Mar 25 '21 07:03 p0g

I think this would be a good addition. The v-model is only for the query, not the selected item. There was some initial hackery with setChangeItem, but providing a prop or other that can set the initial item would be good. initialSelected or something, open to ideas.

re: "too outdated" comment, I am curious if there is anything you feel is outdated with respect to Vue 2.x? I am currently porting it over to support Vue 3.x here: https://github.com/darrenjennings/vue-autosuggest/tree/next/v3

darrenjennings avatar Mar 25 '21 15:03 darrenjennings

I think this would be a good addition. The v-model is only for the query, not the selected item. There was some initial hackery with setChangeItem, but providing a prop or other that can set the initial item would be good. initialSelected or something, open to ideas.

re: "too outdated" comment, I am curious if there is anything you feel is outdated with respect to Vue 2.x? I am currently porting it over to support Vue 3.x here: https://github.com/darrenjennings/vue-autosuggest/tree/next/v3

Hello @darrenjennings! I'm using your component and am trying to set a default value from my :suggestions list. I would like to know if you can show how to, as you said, hack it, and set the default value.

eliumoraes avatar Oct 26 '21 18:10 eliumoraes

I think this would be a good addition. The v-model is only for the query, not the selected item. There was some initial hackery with setChangeItem, but providing a prop or other that can set the initial item would be good. initialSelected or something, open to ideas. re: "too outdated" comment, I am curious if there is anything you feel is outdated with respect to Vue 2.x? I am currently porting it over to support Vue 3.x here: https://github.com/darrenjennings/vue-autosuggest/tree/next/v3

Hello @darrenjennings! I'm using your component and am trying to set a default value from my :suggestions list. I would like to know if you can show how to, as you said, hack it, and set the default value.

I found the solution. The component accepts v-model, you can set the default value that way.

eliumoraes avatar Nov 04 '21 12:11 eliumoraes