Typeahead
When initializing a typeahead
, you pass the plugin method one or more datasets. The source of a dataset is responsible for computing a set of suggestions for a given query.
Prefetched data is fetched and processed on initialization. If the browser supports local storage, the processed data will be cached there to prevent additional network requests on subsequent page loads.
Remote data is only used when the data provided by local and prefetch is insufficient. In order to prevent an obscene number of requests being made to the remote endpoint, requests are rate-limited.
Custom templates give you full control over how suggestions get rendered making it easy to customize the look and feel of your typeahead. This requires Handlebars.js
extension for compilation.
Default suggestions can be shown for empty queries by setting the minLength
option to 0 and having the source return suggestions for empty queries.
For more advanced use cases, rather than implementing the source for your dataset yourself, you can take advantage of Bloodhound
, the typeahead.js
suggestion engine.
Bloodhound is stack, flexible, and offers advanced functionalities such as prefetching, intelligent caching, fast lookups, and backfilling with remote data.
Multiple datasets give you visually separated sets of data inside Dropdown menu with saperate titles
, managed in templates
option. This looks like a <optgroup>
titles in selects.
To change the height of your dropdown menu, just wrap your input in some div
with custom css
styles and change necessary css properties or change it in css directly.
Typeahead supports RTL
also. Wrap your input in any div with text-align: right;
property and add dir="rtl" to your input, now your dropdown menu is right aligned.