How can I bind a variable to key? The currencyList object is being delivered by the Rest Api but I need to bind just the key so that I can pre-select and send back to Rest for an update.
currencyList: [
{key: 1, value: 'First Country'},
{key: 2, value: 'Second Country'},
{key: 3, value: 'Third Country'}
]
multiselect
v-model="vm.selectedCurrencyId"
track-by="key" label="value" placeholder="Select one"
:options="currencyList"
>
Use a computed value passed to :value together with @input handler, instead of v-model.
Read the https://github.com/monterail/vue-multiselect/issues/194 issue response – it might be helpful as it is basically the same case.
I tried this, but does not work (using Vue 2.0)
It doesn't work for me too, so I created the most basic component using bootstrap. But, I would like to replace vue-multiselect at some point.
Me too, I can't make it work. @shentao, according to your available time, could you please provide a working example? (e.g. fiddler)
Thank you
Could you provide some more details?
@coderabsolute the vm.selectedCurrencyId object must contain the key and value properties to be properly preselected. Updating the currencyList should work out of the box.
I have written a tiny component, so I think we can close this issue for now. Thanks for the help!
@coderabsolute if it solves your problem, how about showing it here, so others might find it useful? :)
@shentao for the single select, I got the same issue, until I read your comment here, got it solved.
"the vm.selectedCurrencyId object must contain the key and value properties to be properly preselected"
I think it should pick only the value which is defined by the track-by.
Most helpful comment
@coderabsolute if it solves your problem, how about showing it here, so others might find it useful? :)