Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial selected object #207

Open
p0g opened this issue Nov 5, 2020 · 5 comments
Open

Initial selected object #207

p0g opened this issue Nov 5, 2020 · 5 comments

Comments

@p0g
Copy link

p0g commented Nov 5, 2020

  • 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.

@jesseschutt
Copy link

Were you able to find a solution for this?

@p0g
Copy link
Author

p0g commented Mar 25, 2021

Were you able to find a solution for this?

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

@darrenjennings
Copy link
Owner

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

@eliumoraes
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants