updateOptions

Here we have much-select with no options, click the button to add some options.

Using updateOptions to replace options

Click the button to add some random options (numbers).

You will see that the options get "replaced" not "appended". The exception being that if an option is selected it will stay in the list of options.

Use addOption to add a random value

Click the button to add a random option. And then click it again.

Use addOption to add a value that might be a duplicate

Click the button to add a random option. And then click it again. Eventually you will add all the options in the list. Each time the button is clicked an option is added randomly from a list. You should not get any duplicate items in the list and any selected value should be preserved.

Use removeOption to remove different options

Clicking on a button should remove it from the list of options.

Use selectOption and deselectOption to change the value

Clicking on a button should remove it from the list of options.

Use selectOption to select multiple values to multi select.

Clicking on a button should add them to the selected options.

Changing the DOM to add a selected attribute to one of the options

Here we have options that contain characters that are outside of the standard english alphabet (i.e. diacritics). For the sake of filtering options we match on the the "basic" english letter (filtering is also case insesitive)

To see this in action try filtering on "ra".