Reputation: 2807
I am using Jquery Select2 plugin for Multi Select Dropdown with Check box by referring the below code pen link.
Ref:Please find this [codepen link][1]
https://codepen.io/faur/pen/vWVPGE
When I search for Options List as 'opt' and choosing the element from the Elements. After the selection, my searched term 'opt' still showing in the input box. I want to clear the searched text after selecting the element. How Can I do that?
Upvotes: 2
Views: 1588
Reputation: 31
I had the exact same problem with Select2 Version 4.1.0-beta.1 and I searched for a long time, then I found this solution which use the generic selector for the select and at the time of selection it clears the value of the search__field. For me it worked perfectly. Hope it will work for you too:
$("select").on('select2:select', function (e) {
$('.select2-search__field').val('');
});
Upvotes: 3