如何允许在Bootstrap Select中输入空格?

时间:2018-09-05 17:58:37

标签: twitter-bootstrap bootstrap-select

我希望能够键入一个空格(keycode = 32),但是bootstrap-select不允许我键入它。知道如何允许输入空格吗?

我正在使用v1.11.0

Bootstrap-select v1.11.0

2 个答案:

答案 0 :(得分:3)

可能是其他原因阻止了您进入空间,bootstrap-select并不能阻止您进入空间,请查看以下演示:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.0/css/bootstrap-select.min.css" rel="stylesheet"/>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.0/js/bootstrap-select.min.js"></script>


<select class="selectpicker" data-live-search="true">
  <option>Hot Dog, Fries and a Soda</option>
  <option>Burger, Shake and a Smile</option>
  <option>Sugar, Spice and all things nice</option>
</select>

答案 1 :(得分:0)

//CAN ENTER SPACES
$(function() {
    $('.selectpicker').selectpicker({
          liveSearch: false,
          showSubtext: true
    });
});

//CANNOT ENTER SPACES
$(document).ready(function() {
    $('.selectpicker').selectpicker({
          liveSearch: false,
          showSubtext: true
    });
});