twitter-bootstrap – Bootstrap – 显示焦点上的所有类型头项

栏目: CSS · 发布时间: 6年前

内容简介:http://stackoverflow.com/questions/12827483/bootstrap-show-all-typeahead-items-on-focus

当文本输入(id =“问题”)获取焦点时,我想显示所有Typeahead项目.

我该怎么做?

使用Javascript:

function SetTypeahead() {
    $("#Questions").typeahead({
        minLength: 0,
        source: [
                "Q1?",
                "Q2?",
                "Q3?",
                "@4?"
        ]
    });
}
https://raw.github.com/michaelcox/bootstrap/6789648b36aedaa795f1f5f11b4da6ab869f7f17/js/bootstrap-typeahead.js

获取最新的bootstrap typeahead插件v2.1.2

此更新将允许最小长度为零以启用全部显示

<input id="typeaheadField" name="typeaheadField" type="text" placeholder="Start Typing">

$("#typeaheadField").typeahead({
                        minLength: 0,
                        items: 9999,
                        source: ["Alabama","Alaska","Arizona","Arkansas","California","Colorado", "Oregon"]    
                    });

那么你必须将onFocus事件附加到你的元素,因为它没有被插件定义:

$("#typeaheadField").on('focus', $("#typeaheadField").typeahead.bind($("#typeaheadField"), 'lookup'));

在本地覆盖引导类型头css类也是一个好主意,为结果设置最大高度和垂直滚动,以防结果过多.

.typeahead {
max-height: 200px;
overflow-y: auto;
overflow-x: hidden;
}

http://stackoverflow.com/questions/12827483/bootstrap-show-all-typeahead-items-on-focus


以上所述就是小编给大家介绍的《twitter-bootstrap – Bootstrap – 显示焦点上的所有类型头项》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Tagging

Tagging

Gene Smith / New Riders / 2007-12-27 / GBP 28.99

Tagging is fast becoming one of the primary ways people organize and manage digital information. Tagging complements traditional organizational tools like folders and search on users desktops as well ......一起来看看 《Tagging》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具