Vue-multiselect: Two-way binding model using a custom component

Created on 11 Jan 2017  路  4Comments  路  Source: shentao/vue-multiselect

Hi, thanx for this component.
I'm using it with Vue 2.0 (version 2.0.0-beta.13) and I'm having troubles with v-model

If I directly use <multiselect> inside an HTML file, everything works (even with Ajax, I'm using axios); if I try to write a component (let's say <my-select>), using a .vue file, I can't make it work: the component renders correctly, but my model doesn't get updated when I select a value from the select.

I read the documentation, searched through issues, but I can't figure out how to use two-way binding with v-model, :value / :selected (which of these two?) @insert / @update (which of these two?) .
Sorry for bothering you. Tried various combinations, but I can't make it work.
When I use , which directives / options have I to pass in order to have my model updated?
Could you please provide a short example?

Thanks a lot

help wanted

Most helpful comment

Sure! Always happy to help! 馃槂

All 4 comments

Here a jsfiddle: https://jsfiddle.net/eleftrik/o3x2zzow/

Thank you

For Vue 2.0 this will always be v-model and :value + @input. 1.x uses :selected but doesn鈥檛 support v-model for obvious reasons.

You forgot to add the this.$emit('input', newVal) in the updateSelected method.
Here鈥檚 a working fiddle: https://jsfiddle.net/o3x2zzow/7/

Thank you so much @shentao for your time, I really appreciate your help.

Sure! Always happy to help! 馃槂

Was this page helpful?
0 / 5 - 0 ratings