select2 / select2-bootstrap-theme

A Select2 v4 Theme for Bootstrap 3
https://select2.github.io/select2-bootstrap-theme/
MIT License
872 stars 499 forks source link

select2 opens on disabled #67

Closed brunomiguelpinto closed 11 months ago

brunomiguelpinto commented 7 years ago

When its disabled, the select2 opens on enter and on space. Can someone help?

bmccombs01 commented 7 years ago

You can add a callback that prevents the dropdown from opening on the select2:opening event. Like:

var $select = $("select");
$select.on("select2:opening", function (event) {
  if ($select.is(":disabled")) {
    event.preventDefault();
  }
});

It has been working wonderfully for me.