Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cleaned up the README (OCD 😄 ):
Bootstrap 3 Typeahead
For simple autocomplete use cases there seems to be nothing wrong with the dropped typeahead plugin. Here you will find the typeahead autocomplete plugin for Twitter's Bootstrap 2 ready to use with Twitter's Bootstrap 3. The original code is written by @mdo and @fat.
Users who migrate their website or app from Twitter's Bootstrap 2 to Bootstrap 3 can also use this plugin to keep their current autocomplete functions. See for a complete list of migrations steps: Migrate your templates from Twitter Bootstrap 2.x to Twitter Bootstrap 3
With Twitter Bootstrap 3 the typeahead plugin had been dropped. @mdo says: "in favor of folks using Twitter's typeahead. Twitter's typeahead has more features than the old bootstrap-typeahead.js and less bugs." Twitter's typeahead don't work direct with Bootstrap 3. The DOM structure of the dropdown menu used by
typeahead.js
differs from the DOM structure of the Bootstrap dropdown menu. You'll need to load some additional CSS in order to get thetypeahead.js
dropdown menu to fit the default Bootstrap theme. Try extended Bootstrap LESS or if your are looking for a more extended version try: typeahead.js-bootstrap3.less.Typeahead.js
doesn't seem ready for the new Twitter Bootstrap 3 at the moment. Code is not up to date and fixes are needed. See also:Typeahead problems with Bootstrap 3.0 RC1.
Bootstrap 4
Bootstrap 4 is coming soon. The Bootstrap 3 Typeahead will also work with Bootstrap 4.
The look and feel of Bootstrap 4 will differ from Bootstrap 3 and so does the drop down menu. In Bootstrap 4 the typeahead dropdown menu will look like that shown in the figure below:
.
Download
Download the latest bootstrap3-typeahead.js or bootstrap3-typeahead.min.js.
Include it in your source after jQuery and Bootstrap's JavaScript.
Full integration with Bootstrap 3 Typeahead
Download the latest version of Boostrap from Bootstrap. Copy
bootstrap3-typeahead.js
to the js/ folder. Editgruntfile.js
and addbootstrap3-typeahead.js
to the plugins list.Build your own version with typeahead with
grunt dist
.CSS
There is no additional CSS required to use the plugin. Bootstrap's CSS contains all required styles in the
.dropdown-menu
class. The original CSS adds az-index
of 1051 to the dropdownmenu via the typeahead class. You could add this if you need it..typeahead { z-index: 1051; }
(less or css).Usage
You'll want to set
autocomplete="off"
to prevent default browser menus from appearing over the Bootstrap typeahead dropdown.Via data attributes
Add data attributes to register an element with typeahead functionality as shown in the example above.
Via JavaScript
Call the typeahead manually with:
Destroys previously initialized typeaheads. This entails reverting DOM modifications and removing event handlers:
Javascript Example
Loading a collection
Using JSON objects instead of simple strings
You can add all the properties you wish on your objects, as long as you provide a "name" attribute OR you provide your own displayText method. The other values allow you to match the selected item with something in your model.
Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to
data-
, as indata-source=""
.[]
8
1
"all"
false
"all"
, it will display all hints, not filtering them by the current text. This can be used when you want an input that behaves a bit like a combo box plus auto completion as you type to filter the choices.0
true
$.noop()
0
null
false
false
Methods
.typeahead(options)
: Initializes an input with a typeahead..lookup
: To trigger the lookup function externally.getActive
: To get the currently active item, you will get a String or a JSON object depending on how you initialized typeahead. Works only for the first match.Bower
To use with Bower. Add to your bower.json file:
AngularJS
An AngularJS directive for the Bootstrap 3 Typeahead jQuery plugin can be found at https://github.com/davidkonrad/angular-bootstrap3-typeahead.
Bloodhound
Bloodhound is the typeahead.js suggestion engine, since version 0.10.0. Bloodhound is robust, flexible, and offers advanced functionalities such as prefetching, intelligent caching, fast lookups, and backfilling with remote data. To use Bloodhound with Bootstrap-3-Typeahead:
Bootstrap Tags Input
Bootstrap Tags Input is a jQuery plugin providing a Twitter Bootstrap user interface for managing tags. Bootstrap Tags Input has a typeahead option which allows you to set the source:
or
See also: #40