Reputation: 53
Im using Select2 plugin. My problem is simple - I dont want the dropdown list to show up when Im clearing the option.
Here is my code:
<select class="select2-test" style="width: 20%;">
<option value=""></option>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
</select>
<script>
$('.select2-test').select2({
placeholder: "Choose 1 option",
allowClear: true
});
</script>
I have tried to delete this line from the select2.min.js:
this.on("close",function(){a.$container.removeClass("select2-container--open")})
But it didnt help - the dropdown list wont show up after using it once. Any help will be appreciated. :)
Upvotes: 2
Views: 1588
Reputation: 1057
I advise you not to edit the original js folder. By the way, you can use this, triggering with a click:
$('select').select2("close");
Or you can use the event select2-removing or/and select2-removed, which is a better solution I think (with an event.preventDefault or return false, as you want).
Upvotes: 1