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

input-attrs is not working for ref #61

Open
kevin-netsrik opened this issue May 23, 2018 · 1 comment
Open

input-attrs is not working for ref #61

kevin-netsrik opened this issue May 23, 2018 · 1 comment

Comments

@kevin-netsrik
Copy link

hi all,
input-attrs is not working for ref, the ref attribute is not shown in input search

@StuartMacKay
Copy link

StuartMacKay commented Jul 24, 2018

I added a ref directive with a fixed name, 'input' to the input field in PR #69. If it gets accepted then you would be able to reference the input field using:

this.$refs['autocomplete'].$refs['input']

where 'autocomplete' is any name you would add as a ref to the v-autocomplete component. So for example to set the focus on the input field you would use:

this.$refs['autocomplete'].$refs['input'].focus()

Some other info:

  • I could not get the ref attribute to work when passed in the inputAttrs. I think Vue "compiles" the template long before the value can be set via a property.
  • In case you are wondering why this is useful, I am using the v-autocomplete in a Bootstrap input-group to add people to a separate list. A button allows me to add names of people who don't already exist in the list. Clicking on the button adds the new or selected person to the list. Being able to set the focus on the input field avoids having the user to shift-tab to get back to the field if they want to add another name.

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

No branches or pull requests

2 participants