I am using tag supporting of Select2 for my tag editor, I know you can add a non-existed tag by enter tag and press key "tab"
My question is: I don't want any tags contain space, such as "space tag", so is there any way to set "space" key as a new tag trigger?
(Answered in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With