JQuery select2 breaks as soon as I add tags

As soon as I add tags to my jQuery select2

it breaks and falls back to normal HTML select

.

Here is my code (exactly like this example ):

$(document).ready(function() {
    $("#tags").select2({tags:["red", "green", "blue"]});
});

      

If I remove some of the tags, it works again:

$(document).ready(function() {
    $("#tags").select2();
});

      

+5


source to share


2 answers


If you look into the javascript console, you will see the following error message:

Error: "Tags" checkbox is not allowed for Select2 when connecting to <select>

.



This means that if you want to use the tags parameter, you must apply it to the element input:text

instead select

.

JSFiddle with proof: http://jsfiddle.net/Y8Wc7/

+7


source


Select2 version 4.0.0 now allows you to attach tags to<select>



+7


source







All Articles