Search code examples
vue.jsvue-component

call method when select option from dopdown vue


I have multiselect in vue component. when I select an item from that dropdown it should execute a method. but that method is calling in page load. but I want to call that method when I select an item from dropdown only. how to get it done.

multiselect in vue component

    <multiselect v-model="value" placeholder="Search Categories" @input="updateSelected" :allow-empty="false"
                           :options="categories" :taggable="true" :custom-label='categoriesWithTitle' track-by='id'
                           :show-labels="false">
   </multiselect>

Solution

  • I guess you're using vue-multiselect ? If it's the case, there is a @select event -> Emitted after selecting an option, this one should do the trick.

    Here, your code is triggered on page load because you are probably having some dynamic value on your value prop (@input >> "Emitted after this.value changes").

    https://vue-multiselect.js.org/#sub-events