Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Set selected #70

Open
hrupin opened this issue Aug 27, 2022 · 1 comment
Open

Set selected #70

hrupin opened this issue Aug 27, 2022 · 1 comment

Comments

@hrupin
Copy link

hrupin commented Aug 27, 2022

Good afternoon. Cool plugin! But I can't figure out how to programmatically set the selected options. I'm using the vanilla version.

const myOptions = [ { label: "New York", value: "NY", }, { label: "Washington", value: "WA", }, { label: "California", value: "CA", }, { label: "New Jersey", value: "NJ", }, { label: "North Carolina", value: "NC", }, ]; var instance = new SelectPure(".multi_select", { options: myOptions, multiple: true, icon: "ms_close", });

instance.value(["NY"]) - not work

@liam-milbel
Copy link

Unfortunately the documentation isn't exactly detailed. I had to do this myself (to clear the selected value) and I had to read the source code to figure out what method to call.

On your SelectPure instance, call instance.setSelectValue(instance.options[INDEX]) where INDEX is the index of the option you want to be set.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants