简体   繁体   English

引导程序选择跳转以键入字母

[英]Bootstrap Select jump to typed in letters

Hi Im using Bootstrap Select for a state dropdown and would like to implement the functionality where if a user starts typing "c" then it would drop them down to "california" (as an example). 您好,我使用Bootstrap Select进行状态下拉菜单,并希望实现以下功能:如果用户开始键入“ c”,则它将其下拉至“加利福尼亚”(例如)。 This is already out of the box for plugin but I would like to change where if the user "co" then it would drop them down to "Colorado", instead it takes them first to "california" after typing the "c" and then to "ohio" after typing the "o". 这对于插件来说已经是开箱即用的,但是我想更改用户“ co”的位置,然后将其降至“ Colorado”,而是在键入“ c”后首先将其带到“ california”,然后输入“ o”后,将其改为“ ohio”。 Is there any way to accomplish this with the bootstrap select plugin? 有什么办法可以通过bootstrap select插件来实现?

FYI The plugin is pretty heavily incorporated into the site at the moment and changing to another plugin wouldnt really be an option for me. 仅供参考,目前该插件已被大量整合到网站中,而更改为另一个插件对我来说真的不是一个选择。

Example: http://jsfiddle.net/2a9xp/513/ 示例: http//jsfiddle.net/2a9xp/513/

 $('.selectpicker').selectpicker({size:10}); 
 <link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script> <select class="selectpicker"> <option>California</option> <option>Colorado</option> <option>Connecticut</option> <option>Kansas</option> <option>Kentucky</option> <option>Ohio</option> <option>Oklahoma</option> <option>Oregon</option> </select> 

add to select: data-live-search-style="startsWith" 添加选择: data-live-search-style =“ startsWith”

<select class="selectpicker" data-live-search="true" data-live-search-style="startsWith">

Example: http://jsfiddle.net/vvuhq53g/ 示例: http//jsfiddle.net/vvuhq53g/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM