组件添加下拉按钮

组件添加下拉按钮

本文介绍了向 Twitter bootstrap typeahead 组件添加下拉按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Twitter 引导程序带有一个非常方便的类似自动完成的组件,称为 typeahead.我正在尝试添加一个小的下拉按钮(或小部件),这样当按下 typeahead 组件时,它就像一个普通的下拉选择器,显示所有可用的数据源绑定选项(除了它的本机自动完成功能).当前标记类似于以下内容:

Twitter bootstrap comes with a very handy auto-complete like component called typeahead. I am trying to add a small dropdown button (or widget) such that when pressed the typeahead component would act like a normal dropdown selector showing all of the available data-source bound options (in addition to its native autocomplete ability). The current markup is something like the following:

<input type="text"
       data-provide="typeahead"
       data-items=5
       data-source='["option 1","option 2","option 3"]'>

因此实际上需要的是组件作为下拉和自动完成小部件的混合.以前有人这样做过吗?谢谢...

So in effect what's needed is for the component to behave as a hybrid of a dropdown and autocomplete widgets.Anybody has done this before? thanks...

推荐答案

我发现了这个优秀的组件:

I have found this excellent componnet:

源代码
实例

不过有一点,下拉按钮的背景在鼠标悬停时看起来很有趣.修复涉及对bootstrap-combobox.css"的一个小改动:

One thing though, the drop-down button's background looks funny on rollover. The fix involves a small change in "bootstrap-combobox.css":

...
.combobox-container .add-on {
    float: left;
    display: block;
    width: auto;
    min-width: 16px;
    height: 18px;
    margin-right: -1px;
    padding: 4px 5px;
    font-weight: normal;
    line-height: 18px;
    color: #999999;
    text-align: center;
    text-shadow: 0 1px 0 #ffffff;
    /*   background-color: #f5f5f5; */ // <<------------ comment this line
    border: 1px solid #ccc;
    -webkit-border-radius: 3px 0 0 3px;
    -moz-border-radius: 3px 0 0 3px;
    border-radius: 3px 0 0 3px;
}
...

这篇关于向 Twitter bootstrap typeahead 组件添加下拉按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:42