Disable “No matches found” text and autocomplete on select2

隐身守侯 提交于 2020-06-25 10:38:30

问题


How do you disable the "No matches found" text on autocomplete on select2/Tagging Support?

This is what I have now:

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

But it still shows the "No matches found" message in autocomplete window. I would like to remove this.


回答1:


I think I see what you're getting at... You want to hide the text that says "No matches found" if a user enters a value into that search field that doesn't exist in the list?

You can probably do that in CSS:

.select2-no-results {
    display: none !important;
}

Here's an example.




回答2:


Actually I was using the select2 v4 tags and the code below helped me :

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

I just made the noResults language string to none :

"language":{
          "noResults" : function () { return ''; }
        }

Hope it helps someone




回答3:


For select2 4.0 you can do

.select2-results__message {
    display: none !important;
}



回答4:


.select2-results {
     display: none;
 }

**Just override this **




回答5:


For select 2 4.0 you can do

$('#id').select2({
   minimumResultsForSearch: Infinity
});


来源:https://stackoverflow.com/questions/18470917/disable-no-matches-found-text-and-autocomplete-on-select2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!