As of version 4.0.0, events such as select2-selecting
, no longer work. They are renamed as follows:
- select2-close is now select2:close
- select2-open is now select2:open
- select2-opening is now select2:opening
- select2-selecting is now select2:selecting
- select2-removed is now select2:removed
- select2-removing is now select2:unselecting
Ref: https://select2.org/programmatic-control/events
(function($){_x000D_
$('.select2').select2();_x000D_
_x000D_
$('.select2').on('select2:selecting', function(e) {_x000D_
console.log('Selecting: ' , e.params.args.data);_x000D_
});_x000D_
})(jQuery);
_x000D_
body{_x000D_
font-family: sans-serif;_x000D_
}_x000D_
_x000D_
.select2{_x000D_
width: 100%;_x000D_
}
_x000D_
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet">_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.full.min.js"></script>_x000D_
_x000D_
<select class="select2" multiple="multiple">_x000D_
<option value="1">Option 1</option>_x000D_
<option value="2">Option 2</option>_x000D_
<option value="3">Option 3</option>_x000D_
<option value="4">Option 4</option>_x000D_
<option value="5">Option 5</option>_x000D_
<option value="6">Option 6</option>_x000D_
<option value="7">Option 7</option>_x000D_
</select>
_x000D_