0

I'm trying to start a method after the value of the component Vue Multiselect has been changed using @input, but I'm getting the following compilation error:

CS0103: The name 'input' does not exist in the current context

Here's my multiselect:

<multiselect v-model="Instalacao.value" label="Serie" track-by="Serie" placeholder="Nº de série" :options="Instalacoes"
    :multiple="false" :searchable="true" :allow-empty="false" :disabled="Editando" @input="getTecnicosByRepresentante">
    <span slot="noResult">Nenhum técnico encontrado</span>
</multiselect>
4
  • 1
    Watch Instalacao.value instead. Commented Jan 15, 2019 at 13:24
  • @RoyJ It shouldn't be Instalacoes instead? Commented Jan 15, 2019 at 14:17
  • 1
    No, you want to see when a value has been selected, right? So you can watch the item you used in the v-model. Commented Jan 15, 2019 at 14:20
  • Depends. Can you create a codepen? Commented Jan 15, 2019 at 14:21

1 Answer 1

1

This example works as expected: both the watch and the @input handler execute when you select a value. Your problem is probably not in the code that you included here.

new Vue({
  el: '#app',
  components: {
    Multiselect: window.VueMultiselect.default
  },
  data: {
    Instalacao: {
      value: null
    },
    Instalacoes: [{
        Serie: 'one',
        value: 'Vue.js'
      },
      {
        Serie: 'two',
        value: 'Vue-Multiselect'
      },
      {
        Serie: 'three',
        value: 'Vuelidate'
      }
    ]
  },
  watch: {
    'Instalacao.value': function(newValue) {
      console.log('Updated', newValue);
    }
  },
  methods: {
    getTecnicosByRepresentante() {
      console.log("Input detected, too");
    }
  }
})
<script src="https://unpkg.com/vue@latest/dist/vue.js"></script>
<link href="https://unpkg.com/vue-multiselect@latest/dist/vue-multiselect.min.css" rel="stylesheet" />
<script src="https://unpkg.com/vue-multiselect@latest/dist/vue-multiselect.min.js"></script>
<div id="app">
  <multiselect v-model="Instalacao.value" label="Serie" track-by="Serie" placeholder="Nº de série" :options="Instalacoes" :multiple="false" :searchable="true" :allow-empty="false" @input="getTecnicosByRepresentante">
    <span slot="noResult">Nenhum técnico encontrado</span>
  </multiselect>
  <pre>{{ Instalacao.value }}</pre>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! It's working with the watch, but I don't know yet why it's not accepting @input handler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.