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

Nikul Vyas picture Nikul Vyas · Jul 3, 2018 · Viewed 14.9k times · Source

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.

Answer

Nikul Vyas picture Nikul Vyas · Jul 3, 2018

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