pbauerochse / searchable-option-list

a jquery plugin for a searchable optionlist
MIT License
79 stars 54 forks source link

How can Dynamically updates options #51

Open kapilgp opened 7 years ago

kapilgp commented 7 years ago

Hi,

Is there any option to update the list of options. I mean we have to update the options dynamically. if not then how we can destroy and re-initialize?

Novakinify commented 7 years ago

Did you make any progress on this ?

kapilgp commented 7 years ago

Yes, I have apply a hack in plugin for it:

Go to plugin line 1052

if ($alreadyInitializedSol) { result.push($alreadyInitializedSol);

And Replace it by: if ($alreadyInitializedSol) { //result.push($alreadyInitializedSol); $alreadyInitializedSol.$container.html(''); var newSol = new SearchableOptionList($this, options); result.push(newSol); setTimeout(function () { newSol.init(); }, 0);

After than you just need to update options in select box And re-bind searchOptionList like:

$('#test').searchableOptionList({ maxHeight: '180px', showSelectAll: true })

Novakinify commented 7 years ago

Great, thanks man, it works like this :D You saved my time...