Override Minimum length string of Select2

前端 未结 4 1606
梦毁少年i
梦毁少年i 2021-01-01 14:13

Select2 Jquery Plugin

I was having hard time how to override the default message for minimum length input in jquery Select2.

by default the plugin gives th

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 14:59

    select2 extended for localization override strings

    $.fn.select2.defaults = $.extend($.fn.select2.defaults, {
    formatMatches: function (matches) { return matches + $filter('translate')('label.matches.found'); },
    formatNoMatches: function () { return $filter('translate')('noMatches.found'); },
    formatInputTooShort: function (input, min) { var n = min - input.length; return $filter('translate')('label.please.enter ') + n + $filter('translate')(' more.characters')+ (n == 1? "" : "s"); },
    formatInputTooLong: function (input, max) { var n = input.length - max; return $filter('translate')('please.delete ') + n + $filter('translate')('')('delete.characters') + (n == 1? "" : "s"); },
    formatSelectionTooBig: function (limit) { return $filter('translate')('select.only') + limit + $filter('translate')('select.item ') + (limit == 1 ? "" : "s"); },
    formatLoadMore: function (pageNumber) { return $filter('translate')('load.results'); },
    formatSearching: function () { return $filter('translate')('label.search'); }
    });
    }
    

提交回复
热议问题