How to customize select2 messages?

1

I want to remove Select2 messages:

  • Searching;
  • No matches found;
  • Follow the code below:

    Html Page

    <input id="ajaxSecretaria" type="hidden" style="width:300px" />
    

    Script:

    $(function () {
        $('#ajaxSecretaria').select2(
        { minimumResultsForSearch: -1,
          ajax: {
            url: '@Url.Action("GetSecretarias", "Home")',
            dataType: 'json',
            data: function (term, page) {
                return { searchTerm: term };
            },
            results: function (data, page) {
                     return {results: data};
            }
        }
       });
    });
    
        
    asked by anonymous 27.07.2018 / 17:36

    1 answer

    0

    Very simple to customize just put the instructions below in the call of your javascript like this:

    formatNoMatches: function () {return "Search not found"; }, formatInputTooShort: function (input, min) {return "Enter" + (min - input.length) + "characters to search"; }, formatSelectionTooBig: function (limit) {return "Select only 1 option" + limit + "item" + (limit == 1? "": "s"); }, formatLoadMore: function (pageNumber) {return "Loading more data ..."; }, formatSearching: function () {return "Searching ..."; },

    Any questions please let me know.

        
    02.08.2018 / 17:53