Select2:不能创建超过2个字符的新选项(标记:true) [英] Select2: Can't create new options longer than 2 characters (tag: true)

查看:76
本文介绍了Select2:不能创建超过2个字符的新选项(标记:true)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Select2 Box,启用了标记以添加新的自己的标记.选择一个现有选项不会有任何问题(任何长度).但是有些代码使我无法添加长度超过2个字符的新选项(只是不能添加更多字符).参见 JSFiddle

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>

用于初始化select2的jQuery代码

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.

推荐答案

似乎是最新的select2.js库4.0.7和jQuery 3.4.x之间的错误/兼容性问题.请参阅Github上的问题: https://github.com/select2/select2/issues/5485

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

更新:已在4.0.8版中修复

UPDATE: Got fixed in version 4.0.8

这篇关于Select2:不能创建超过2个字符的新选项(标记:true)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆