M
M
mrWan2017-09-01 19:05:48
Bootstrap
mrWan, 2017-09-01 19:05:48

No results matched select2. How to change this text to Russian?

Read the documentation, found nothing! Who can faced it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mrWan, 2017-09-01
@mrWan


here is my code not working :

<select id="select-typepart" name="typepart" class="selectpicker form-control"  data-max-options="3" data-live-search="true">
<option value="0">не выбрано</option>
<option value="1">выбрано1</option>	
<option value="2">выбрано2</option>				
</select>

<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.5/js/bootstrap-select.min.js"></script>
    $('select[name="typepart"]').select2({  // и по id пробовал выбирать и просто по селектору
        language: {
          noResults: function (params) {
            return "Нет результатов ... или что-то ещё";
          }
        }
      });

S
shilovk, 2017-10-10
@shilovk

It all depends on the version of Select2.
In my case, when using version 3.5.3 , this parameter is set using formatNoMatches:

$('#search-select').select2({
  formatNoMatches: function () {
  return "Нет результатов ... или что-то ещё";
  }
});

In other versions, this parameter is referred to as noResults, and possibly noMatches.
Usage:
$('#search-select').select2({
   "language": {
       "noResults": function(){
           return "Нет результатов ... или что-то ещё";
       }
   }
});

It may also be useful to switch the language:
$('#search-select').select2({
  "language": "ru"
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question