fastselect icon indicating copy to clipboard operation
fastselect copied to clipboard

Programmatically add/remove options?

Open DiMono opened this issue 7 years ago • 6 comments

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?

DiMono avatar Oct 01 '18 18:10 DiMono

I have same question..

tgurinder avatar Nov 26 '18 11:11 tgurinder

I have t he same question as well...

Erth0 avatar Jan 22 '19 21:01 Erth0

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

Erth0 avatar Jan 22 '19 21:01 Erth0

@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});

DiMono avatar Jan 22 '19 21:01 DiMono

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

Erth0 avatar Jan 22 '19 23:01 Erth0

@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);

DiMono avatar Jan 22 '19 23:01 DiMono