vue-multiselect icon indicating copy to clipboard operation
vue-multiselect copied to clipboard

how to set selected? :value prop is ignored

Open vue-fan opened this issue 5 years ago • 3 comments

Steps to reproduce

 <multiselect
        v-model="form.empresa"
        :value="form.empresa"
        :options="empresas"
        :multiple="false"
        track-by="id"
        label="empresa"
        tag-placeholder="{{ __('Select Empresa') }}"
        placeholder="{{ __('Empresa') }}">
        </multiselect>

import AppForm from '../app-components/Form/AppForm';

Vue.component('admin-user-form', {
    mixins: [AppForm],
    props: ['empresas'],
    data: function() {
        return {
            form: {
                first_name:  '' ,
                last_name:  '' ,
                email:  '' ,
                password:  '' ,
                activated:  false ,
                forbidden:  false ,
                language:  '' ,
                empresa:  '' ,
                
            }
        }
    }
});

Expected behaviour

i wanto to set the selected options when im editing an item

Actual behaviour

it doesn't work

vue-fan avatar Jan 10 '20 23:01 vue-fan

Having a similar issue. No matter what value I set :value to, it fails to represent this. v-model functions as expected, but :value appears to have no effect, even in a simple implementation like this:

const testValue = ref('foo');
const testOptions = ref(['foo', 'bar', 'baz']);

<VueMultiselect :value="testValue" :options="testOptions" ...>

The result is a list of my options in the dropdown, but 'foo' is not preselected as would be expected.

davevasquez avatar Dec 21 '22 21:12 davevasquez

I've just tried and had no luck with this either, the fact that this is three and a half-year-old issue and hasn't been addressed is quite concerning...

nthndnn avatar Aug 03 '23 14:08 nthndnn

Hi there. Can we have a reproduce-able example using something like https://jsfiddle.net/mattelen/8cyt3hrn/5/ or something similar. @nthndnn since you've had this one recently, it would be great an example so I can jump in and see what is going on, and issue a fix if needed. TIA

mattelen avatar Aug 04 '23 13:08 mattelen