Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a function on selection change in v-select? [duplicate]

I am currently working on Vuetify, trying to call a method in Vue.js from v-select using HTML. But the @change event is not properly selecting the conditions.

<v-layout row wrap>
    <v-flex xs12 sm4>
      <!-- DropDown Combo -->
      <v-select v-model="selected"
        :items='dropdown_tables'
        append-icon='fa-angle-down'
        label='Select'
        persistent-hint
        return-object
        single-line
        @change='RefreshGrid'
        target='#dropdown'>
        </v-select>
        <!-- <p> {{`${selected}`}} </p> // this code gives the selected combo text -->
    </v-flex>
   </v-layout>
</v-container>

My Javascript function

 methods: {
   RefreshGrid: function () {
   let cName;
   if (this.selected === 'Business Area') {
    cName = 'businessArea';
   } else if (this.selected === 'Council') {
     cName = 'council';
   }
   let obj = {
    vm: this,
    collectionName: cName,
    action: 'masterData/setMasterData',
    mutation: 'setMasterData'
   };
   this.$store.dispatch(obj.action, obj);
 }

So when I use on change, and click on council it shows businessArea data in grid and vice versa. Trying to figure out how the indexing of v-select works.

like image 882
Nikul Vyas Avatar asked Dec 06 '22 11:12

Nikul Vyas


1 Answers

So, using @input instead of @change works fine.

like image 154
Nikul Vyas Avatar answered Dec 25 '22 22:12

Nikul Vyas