禁用"找不到匹配项"文本并在select2上自动完成

ale*_*oid 5 html javascript css jquery-select2

如何在select2/Tagging Support上禁用自动完成时"找不到匹配"文本?

这就是我现在拥有的:

$('#ProductDescriptions_30_keywords').select2({
        tags:[],
        tokenSeparators: [",", " "],
        minimumResultsForSearch: -1
        }
    );
Run Code Online (Sandbox Code Playgroud)

但它仍然显示自动完成窗口中的"找不到匹配"消息.我想删除它.

Sim*_*ock 12

我想我看到你得到了什么...如果用户在列表中不存在的搜索字段中输入值,你想要隐藏"找不到匹配项"的文本?

您可以在CSS中执行此操作:

.select2-no-results {
    display: none !important;
}
Run Code Online (Sandbox Code Playgroud)

这是一个例子.


raz*_*bee 8

实际上我使用的是 select2 v4 标签,下面的代码帮助了我:

 $(document).find(".email_contact_search").select2({
    tags: true,
    tokenSeparators: [','],
    "language":{
      "noResults" : function () { return ''; }
    }
  });
Run Code Online (Sandbox Code Playgroud)

我只是将 noResults 语言字符串设为 none :

"language":{
          "noResults" : function () { return ''; }
        }
Run Code Online (Sandbox Code Playgroud)

希望它可以帮助某人