I used the typeahed.js for tag creation, but later i decided to have each option with an id, so i changed to select2 4.0.13 (latest, stable). The select2 box loads all options which were previously created, but the user must be able to add new values too. So i enabled the Tag system on select2 with Token separator the comma [","].
The problem is on Greek punctuation. When i start typing after the first letter i can not add any letter with punctuation like "?"..
This happens only after the first letter, because on the first letter i can add punctuation as normal.
After the first letter whenever i want to add punctuation the char of punctuation is stored like a standalone character like "?α"
$("body .m-select2-custom-fields-values").select2({
minimumResultsForSearch: '5',
allowClear:!0,
minimumInputLength:0,
tags: true,
width: '100%',
tokenSeparators: [','],
}).on("change", function(e) {
var isNew = $(this).find('[data-select2-tag="true"]');
if(isNew.length && $.inArray(isNew.val(), $(this).val()) !== -1){
isNew.replaceWith('<option selected value="'+isNew.val()+'">'+isNew.val()+'</option>');
console.log(isNew.val());
}
}).on("keydown", function(e) {
if (e.keyCode == 13) {
alert();
}
});
question from:
https://stackoverflow.com/questions/65644486/select2-problem-with-new-tag-on-greek-punctuations 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…