Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable "No matches found" text and autocomplete on select2

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.

like image 775
alexanoid Avatar asked Aug 27 '13 16:08

alexanoid


2 Answers

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.

like image 80
Simon Adcock Avatar answered Oct 20 '22 08:10

Simon Adcock


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

like image 10
razzbee Avatar answered Oct 20 '22 10:10

razzbee