Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroying and Reinitializing a selectpicker with title generates an empty option at index 0 #2491

Closed
Slowey opened this issue Jun 25, 2020 · 1 comment
Labels

Comments

@Slowey
Copy link

Slowey commented Jun 25, 2020

Environment:
Boostrap 4
Boostrap-select 1.13.17
jQuery version 3.4.1
Windows 10
Chrome 83.0.4103.97

I've been trying to dynamically change my bootstrap-select dropdown between multiselect and singleselect using javascript.
My way of going about this has been to remove/add the attribute multiple to my select element and then reinitialize the selectpicker component (selectpicker.destroy + selectpicker).
This leads to a bug were an extra option is added when switching from single select to multi select. It seems to have something to do with the title attribute. If the title attribute is empty string or the title attribute is not set this problem does not occur.

I have created a plunker demo below with a single select list with only 1 option and a button that toggles the code I wrote to switch between single/multi-select:
https://plnkr.co/edit/DwR6cCzLigExMpH6?preview

Try clicking the button a couple of times, try reloading the site and removing the title attribute.

Is this the wrong way to go about my problem? Is there another better solution to switch between multi/single-select during runtime?

BR,
Lucas

@caseyjhol
Copy link
Member

Released in v1.13.18!

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

No branches or pull requests

2 participants