vue2-autocomplete icon indicating copy to clipboard operation
vue2-autocomplete copied to clipboard

how to get v-model

Open raajshekhar opened this issue 7 years ago • 6 comments

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 avatar Feb 18 '18 18:02 raajshekhar

@raajshekhar the selected object is passed as a param with the onSelect event, eg:

:onSelect="getData"

methods: {
  getData: function(userSelectedObject) {
    console.dir(userSelectedObject);
  }
}

constantm avatar Feb 22 '18 10:02 constantm

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.

molerat619 avatar Feb 24 '18 21:02 molerat619

I would like to know this as well...

yordivd avatar Apr 03 '18 09:04 yordivd

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=

constantm avatar Apr 03 '18 10:04 constantm

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?

MichaelJPDX avatar Apr 05 '18 02:04 MichaelJPDX

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.

taianrj avatar Oct 28 '19 12:10 taianrj