我正在为我的标签编辑器使用支持 Select2 的标签,我知道您可以通过输入标签并按下“tab”键来添加一个不存在的标签
我的问题是:我不希望任何标签包含空格,例如“空格标签”, 那么有什么办法可以将“空格”键设置为新的标签触发器吗?
最佳答案
(在问题编辑中回答。转换为社区维基答案。参见 Question with no answers, but issue solved in the comments (or extended in chat))
OP 写道:
After some digging, I solved my question by
$("#e20").select2({
tags:["red", "green", "blue"],
tokenSeparators: [",", " "]
});
The key point is the
tokenSeparators
attribute.And the document of Select2 is useful.
关于javascript - 如何将 Select2 默认新标签键 "tab"更改为 "space"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16388065/