Run a method by onChange with q-select (Quasar Framework)

Viewed 11432

The function isn't running when I change the selected value. How do i fix this? Here is my code:

<q-select
  v-model="single"
  :options="['def', 'abc', '456', '123']"
  use-chips
  label="Select One"
  @input="showChannel()"
/>

JavaScript code:

methods: {
  showChannel(val) {
    console.log(val);
  }
}
4 Answers

Use @update:model-value instead of @input. (I used Quasar v2.0.3)

So, this is your case below:

<q-select
  v-model="single"
  :options="['def', 'abc', '456', '123']"
  use-chips
  label="Select One"
  // @update:model-value instead of @input 
  @update:model-value="showChannel()" 
/>

Sometimes, Quasar is tricky.

<q-select
  v-model="single"
  :options="['def', 'abc', '456', '123']"
  use-chips
  label="Select One"
  // @update:model-value instead of @input 
  @update:model-value="val => showChannel(val)" 
/>

For those who use Quasar v2, they changed the event from input to input-value

I just noticed the events in the documentation. I changed the keyword "change" to "input" and it started working.

Related