选择2版本:
4.0.5
问题:
在多任务处理中(带标记:true或带预填充标记),每当我按enter键选择标记时,它都会创建标记,但会将文本保留在新标记的右侧,如果之后按另一个键,它就会消失。(仅在使用Enter键时发生)
例子:
如您所见,当我键入标记并按Enter键时,它会创建标记(预期行为),但会将原始文本保留在新标记的右侧。。。
这是正常的行为吗?或者我该怎么办?
我的Select2代码:
var editorTagElement = document.createElement("select");
editorTagElement.className('myEditor');
editorTagElement.setAttribute("multiple", "multiple");
editorTagElement.style.overflow = 'auto';
editorTagElement.style.fontSize = '13px';
this.OptionsSelect2 = {};
this.OptionsSelect2.placeholder = "";
this.OptionsSelect2.language = ReturnCustomLanguage();
this.OptionsSelect2.formatNoMatches = function () {
return '';
};
this.OptionsSelect2.allowClear = true;
this.OptionsSelect2.minimumInputLength = 2;
this.OptionsSelect2.tags = true;
this.OptionsSelect2.tokenSeparators = [' '];
this.OptionsSelect2.createTag = function (params) {
var term = $.trim(params.term);
if (term.length < 2) {
return null;
}
term = term.replace(/ /g, "");
return {
id: term,
text: term,
newTag: true
}
};
this.OptionsSelect2.closeOnSelect = false;
$('.myEditor').select2(this.OptionsSelect2);
在此之后,我将编辑器附加到正文或html中的其他位置。。。