As soon as I add tags to my jQuery select2
it breaks and reverts back to the normal HTML select
box.
Here is my code (exactly like this example):
$(document).ready(function() {
$("#tags").select2({tags:["red", "green", "blue"]});
});
If I remove the tags part it works again:
$(document).ready(function() {
$("#tags").select2();
});
If you look in your javascript console you will see the following error message:
Error: Option 'tags' is not allowed for Select2 when attached to a
<select>
element.
That means, when you want to use the 'tags' option, you have to apply it to an input:text
element instead of a select
.
JSFiddle with proof: http://jsfiddle.net/Y8Wc7/
Select2 version 4.0.0 now allows tags to be attached to a <select>
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