vue2-autocomplete
vue2-autocomplete copied to clipboard
how to get v-model
I have used this autocomplete. i need the user selected data but here i didn't v-model, so how can i get the data
@raajshekhar the selected object is passed as a param with the onSelect
event, eg:
:onSelect="getData"
methods: {
getData: function(userSelectedObject) {
console.dir(userSelectedObject);
}
}
And how do you pass another parameter to that function?
I am using this in a v-for and on select I need to assign the selected item to the respective item in the array I am iterating over. Like so:
<tr v-for="task in tasks">
<td><autocomplete... :onSelect="getData"></autocomplete></td>
</tr>
getData
needs to know which task
to add the selected item to.
I would like to know this as well...
If you're using more than one autocomplete, it might make sense to wrap them in a parent component and then keep the relevant data you'd like to access there. Otherwise, you can also add the parameter you're trying to pass to the data itself, so it gets passed to the function set with :onSelect=
And, if I don't select a value but continue typing to establish a new value, how do I get the typed value to post?
And, if I don't select a value but continue typing to establish a new value, how do I get the typed value to post?
I've added :on-input="inputRepository" and now it's getting the value typed.