ajaxvue.jsloopsv-select

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


Have the following vue loop

<div class="row w-100 form-group" v-for="(item, index) in affectedParties">
    ...
    <div class="col-md-6">
        <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.


Solution

  • 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)"