Change Select2 To Display 'n Of M Items Selected'
I like to use the Select2 plugin with tagging enabled, like in this example: https://select2.github.io/examples.html#tags However I would like to change it to display a text like
Solution 1:
You can do it easy like this. No rape select2 is needed :)
$("#singleSelectExample").select2({
closeOnSelect: false
});
$('#singleSelectExample').on('change', function() {
var selected = $(this).val().length;
varof = $(this).find('option').length;
$(this).parent().find('.select2-selection ul').html('Selected ' + selected + ' of ' + of + ' items.')
});
Solution 2:
https://select2.github.io/examples.html#events
With event you can do it. Fire the select event and update your text.
Post a Comment for "Change Select2 To Display 'n Of M Items Selected'"