dbrekalo / fastselect

Fastselect is lightweight browser plugin for enhanced select elements based on jQuery. Enables fast and sensible UI upgrade of select element with features like option searching and remote dataset loading.
http://dbrekalo.github.io/fastselect/
MIT License
108 stars 87 forks source link

Programmatically add/remove options? #40

Open DiMono opened 6 years ago

DiMono commented 6 years ago

I have a multiselect which might have options added to or removed from it after the data is loaded and the fastselect is initialized. Is there a way to programmatically add/remove them from the rendered fastselect without de-initializing it, adding/removing the option directly, and re-initializing it?

tgurinder commented 5 years ago

I have same question..

Erth0 commented 5 years ago

I have t he same question as well...

Erth0 commented 5 years ago

@DiMono How can you de-initialize that I am breaking my head and still doesn't work

DiMono commented 5 years ago

@Erth0 you do it as follows:

mymultiselect = new $.Fastselect($('#myselect'),{param1: value1, etc});

[. . . stuff happens . . .]

mymultiselect.destroy();
$('#myselect').WhateverNeedsDoing;
mymultiselect = new $.Fastselect($('#myselect'),{param1: value1, etc});
Erth0 commented 5 years ago

@DiMono I am able to destroy that however when I edit back again the options are still there

DiMono commented 5 years ago

@Erth0 The following works for me. If it doesn't work for you, then I'm out of ideas.

mymultiselect.destroy();
$(OptionToRemove).remove();
mymultiselect = new $.FastSelect(etc);