Can't get paste to work with select2 4.0 to insert multiple items

The insert was used in previous versions of select2, taking tokenSeparator

in account to split the inserted term into multiple tags.

Now I just can't get it to run.

This is how I call select2:

$('select').select2({
  tags: true,
  multiple: true,
  tokenSeparators: [',', ' '],
  width: 200
 });

      

Example: http://codepen.io/anon/pen/oXoXqO . Try to insert:Gods,Angels,Devils

I also tried using the method tokenizer

as described here: Automatically tokenizing the last item in the inserted row using select2 , but got this error: select2.js:3503 Uncaught TypeError: Cannot read property 'term' of undefined

+3


source to share


2 answers


This is a known issue in select2 4.0.0, documented here: https://github.com/select2/select2/issues/3458



+3


source


I also tried to write my own tokenizer, but it seems that somehow select2 4.0.x

also calls it a custom tokenizer (and why did you get this error, @Eric Saboia).



I couldn't fix this correctly, so I would suggest either expecting bug fixes using a similar working lib like http://selectize.github.io/selectize.js/ or writing your own component (probably with React).

0


source







All Articles