Select2 Multiple empty option bug
Select2 Multiple empty option bug

Hi,
I've found that if using select2 with multiple set to true then when you make your first selection it adds the empty option tag as selected also. If you select nothing and close and reopen then you will end up with 2 empty options showing as selected, and so on each time you close and reopen. This also results in the placeholder only displaying half of the text on the first open.
I believe the issue is that for a multiple select2 an empty option tag should not be used. The only way I've found to get around this is to add the below on open of editor and again on close in order to remove the empty option.
$(selectElem).empty();
I've done a lot of searching and couldn't seem to find anything relating to this same issue, apologies if it has been addressed.
Replies
Hi,
I don't recall having seen that issue before either. Can you give me a link to your page so I can take a look at it?
Thanks,
Allan
Hi Allan,
Sorry only just seen this, the page isn't accessible so i'll set something up to show you.
Thanks,
Nick
Hi Allan,
It's just occurred to me that it's not possible to provide a test case for editor due to it's license requirements. Perhaps I could provide some screenshots of the issue and provide the demo code for it?
Thanks,
Nick
Hi @nmase88 ,
Here's a basic test case - would you be able to modify this to demonstrate your problem?
Cheers,
Colin
Are you using ajax? If so, Select2 field plugin making unnecessary ajax calls might be relevant as I had a similar issue.
Hi @colin,
That's great thank you! I'll have a go at setting this up later
.
@mguinness I am using ajax to a degree but it's not making any additional calls it's just adding empty options to the dropdown. thanks for the suggestion though.
Hi @colin ,
Any change that basic test case can include select2?
Thanks,
Nick