Home > Mobile >  Pass the index value to the search function for v-select inside a loop
Pass the index value to the search function for v-select inside a loop

Time:08-31

Have the following vue loop

<div  v-for="(item, index) in affectedParties">
    ...
    <div >
        <v-select label="text" :filterable="false" :options="item.affecteds" v-on:search="fetchAffected" v-model="item.selectedAffected" placeholder="Selected"></v-select>
    </div>
</div>

I need to pass the index so i can properly get the options that will feed the v-select since I'll be doing a query thru an ajax call.

Usually you would function (search, loading) as the documentation says, but i dont know how to change this to a custom function that will accept a custom parameter.

And I cant find any example or documentation on how to send a custom parameter to the function for the search event.

CodePudding user response:

Try to use an inline handler and call the method with inline handler parameters and the index :

<v-select v-on:search="(search,loading)=>fetchAffected(search,loading,index)"
  • Related