Select2: Can't create new options longer than 2 characters (tag: true)
Asked Answered
P

2

5

I have a Select2 Box, with tagging enabled to add new own tags. Selecting an existing option works without any problem (of any length). But some code prevents me from adding a new option longer than 2 characters long (just can't add more characters). See the JSFiddle

<select class="form-control select2" multiple="multiple" id="employee-groups-select" name="employee[employee_group_ids][]">
    <option value="4">Text1</option>
    <option value="1">Text2</option>
    <option value="3">Text3</option>
    <option value="2">Text4</option>
</select>

jQuery code to initialize the select2

$('#employee-groups-select').select2({
          theme: 'bootstrap4',
          tags: true,
          width: '100%',
          tokenSeparators: [',', ' '],
 });

Help is highly appreciated. I have no idea where to look.

Pugging answered 8/5, 2019 at 18:5 Comment(2)
How you are doing this?: But some code prevents me from adding a new option longer than 2 characters longAurangzeb
@Dani, please see the JSFiddle provided in the description: jsfiddle.net/rqyzupjv/2Pugging
P
11

Seems to be a bug / compatibility issue between the latest select2.js library 4.0.7 and jQuery 3.4.x. See the issue on Github: https://github.com/select2/select2/issues/5485

UPDATE: Got fixed in version 4.0.8

Pugging answered 9/5, 2019 at 12:51 Comment(0)
N
1

The slect2 4.0.8 appears to fix it, here it works!

Neoplatonism answered 13/8, 2019 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.