@danielfarrell/bootstrap-combobox

中文文档
1.1.8发布于 2017/03/19Apache-2.0CommonJS零依赖近 30 天下载 6007

A combobox plugin that works with twitter bootstrap

原始使用文档
文档目录8 节
  1. How to install it
  2. How to use it
  3. Options
  4. Dependencies
  5. Live Example
  6. Bootstrap 2.0 Version
  7. Bootstrap 3.0 Version
  8. License

Bootstrap Combobox

We had need of a combobox at work and after looking around at the available options I was not happy with any of them. The project had all it's styling based on Twitter's Bootstrap, so building on that made sense.

How to install it

You can install this plugin one of two ways.

1. Manual download

Previously, this was the only way to install the plugin. You will need two files included in your HTML in order for this to work:

  1. js/bootstrap-combobox.js
  2. css/bootstrap-combobox.css

2. Bower install

This plugin is now in bower! If you've already installed bower on your machine, simply use the command:

bower install bootstrap-combobox

This will install the plugin to your bower_components folder. For more information please see http://bower.io/

How to use it

The dependencies are the Bootstrap stylesheet(CSS or LESS). Include it and then the stylesheet(CSS or LESS) and javascript.

Then just activate the plugin on a normal select box(suggest having a blank option first):

<select class="combobox">
  <option></option>
  <option value="PA">Pennsylvania</option>
  <option value="CT">Connecticut</option>
  <option value="NY">New York</option>
  <option value="MD">Maryland</option>
  <option value="VA">Virginia</option>
</select>

<script type="text/javascript">
  $(document).ready(function(){
    $('.combobox').combobox();
  });
</script>

Options

When activating the plugin, you may include an object containing options for the combobox

$('.combobox').combobox({bsVersion: '2'});

menu: Custom markup for the dropdown menu list element.

item: Custom markup for the dropdown menu list items.

matcher: Custom function with one item argument that compares the item to the input. Defaults to matching on the query being a substring of the item, case insenstive

sorter: Custom function that sorts a list items for display in the dropdown

highlighter: Custom function for highlighting an item. Defaults to bolding the query within a matched item

template: Custom function that returns markup for the combobox.

bsVersion: Version of bootstrap being used. This is used by the default template function to generate markup correctly. Defaults to '3'. Set to '2' for compatibility with Bootstrap 2

appendId: The desired id of the transformed combobox. This will become the id attr and can be mapped to a label using the for attribute. Useful for accessibility.

Dependencies

Uses the latest 1.X version of jQuery and the latest 2.X or 3.X of bootstrap.

Live Example

Bootstrap 2.0 Version

http://dl.dropbox.com/u/21368/bootstrap-combobox/index.html

Bootstrap 3.0 Version

http://bootstrap-combobox-test.herokuapp.com/

License

Licensed under the Apache License, Version 2.0

版本与发布记录

@danielfarrell/bootstrap-combobox 共发布 1 个版本,首次发布于 2017/03/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.8latest2017/03/199 年前

关于 @danielfarrell/bootstrap-combobox 的常见问题

@danielfarrell/bootstrap-combobox 是什么?

A combobox plugin that works with twitter bootstrap

如何安装 @danielfarrell/bootstrap-combobox?

在项目目录运行 npm install @danielfarrell/bootstrap-combobox,或使用 pnpm add / yarn add / bun add。

@danielfarrell/bootstrap-combobox 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/danielfarrell__bootstrap-combobox 是否存在。

@danielfarrell/bootstrap-combobox 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@danielfarrell/bootstrap-combobox 可以商用吗?

@danielfarrell/bootstrap-combobox 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@danielfarrell/bootstrap-combobox 的下载量有多少?

根据 npm 官方下载统计,@danielfarrell/bootstrap-combobox 在 2026/10/11 – 2026/11/09 这 30 天内被下载 6,007 次,日均约 200 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@danielfarrell/bootstrap-combobox 还在维护吗?

最新版本 1.1.8 发布于 2017/03/19(9 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/03/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。