Gathering detailed insights and metrics for @universityofwarwick/bootstrap-3-typeahead
Gathering detailed insights and metrics for @universityofwarwick/bootstrap-3-typeahead
Gathering detailed insights and metrics for @universityofwarwick/bootstrap-3-typeahead
Gathering detailed insights and metrics for @universityofwarwick/bootstrap-3-typeahead
react-bootstrap-typeahead
React typeahead with Bootstrap styling
bootstrap-3-typeahead
Bootstrap 3 Typeahead: The typeahead autocomplete plugin for Twitter's Bootstrap 2 ready to use with Bootstrap 3.
@types/react-bootstrap-typeahead
TypeScript definitions for react-bootstrap-typeahead
jest-watch-typeahead
Jest plugin for filtering by filename or test name
npm install @universityofwarwick/bootstrap-3-typeahead
72.8
Supply Chain
99.4
Quality
81.1
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
303 Commits
5 Watching
10 Branches
10 Contributors
Updated on 21 Nov 2023
Minified
Minified + Gzipped
JavaScript (64.47%)
HTML (35.53%)
Cumulative downloads
Total Downloads
Last day
10%
22
Compared to previous day
Last week
54.9%
79
Compared to previous week
Last month
-48.5%
290
Compared to previous month
Last year
183.9%
5,534
Compared to previous year
This is a fork of bassjobsen/Bootstrap-3-Typeahead which in turn is a fork of the Bootstrap 2 library.
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 the typeahead.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 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 the latest bootstrap3-typeahead.js or bootstrap3-typeahead.min.js.
Include it in your source after jQuery and Bootstrap's JavaScript.
Download the latest version of Boostrap from Bootstrap. Copy bootstrap3-typeahead.js
to the js/ folder. Edit gruntfile.js
and add bootstrap3-typeahead.js
to the plugins list.
Build your own version with typeahead with grunt dist
.
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 a z-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).
<div>
<input type="text" class="typeahead" data-provide="typeahead">
</div>
You'll want to set autocomplete="off"
to prevent default browser menus from appearing over the Bootstrap typeahead dropdown.
For compliance with the new ARIA 1.1 standard, the typeahead will attach some aria- attributes to the parent element of the input you call it on. This is not likely to be an issue in most cases, but you should check whether or not the input needs a wrapper element before applying the 4.1.0 update.
Add data attributes to register an element with typeahead functionality as shown in the example above.
Call the typeahead manually with:
1$('.typeahead').typeahead()
Destroys previously initialized typeaheads. This entails reverting DOM modifications and removing event handlers:
1$('.typeahead').typeahead('destroy')
1$.get("example_collection.json", function(data){ 2 $("#name").typeahead({ source:data }); 3},'json'); 4//example_collection.json 5// ["item1","item2","item3"]
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.
1var $input = $(".typeahead"); 2$input.typeahead({ 3 source: [ 4 {id: "someId1", name: "Display name 1"}, 5 {id: "someId2", name: "Display name 2"} 6 ], 7 autoSelect: true 8}); 9$input.change(function() { 10 var current = $input.typeahead("getActive"); 11 if (current) { 12 // Some item from your model is active! 13 if (current.name == $input.val()) { 14 // This means the exact match is found. Use toLowerCase() if you want case insensitive match. 15 } else { 16 // This means it is only a partial match, you can either add a new item 17 // or take the active if you don't want new items 18 } 19 } else { 20 // Nothing is active so it is a new value (or maybe empty value) 21 } 22});
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-source=""
.
If you are using jQuery in your application, note that camel case attributes such as data-minLength
should be formatted as data-min-length
. If you want more explanation, see this issue.
Name | Type | Default | Description |
---|---|---|---|
source | array, function | [] | The data source to query against. May be an array of strings, an array of JSON object with a name property or a function. The function accepts two arguments, the query value in the input field and the process callback. The function may be used synchronously by returning the data source directly or asynchronously via the process callback's single argument. |
items | number | 8 | The max number of items to display in the dropdown. Can also be set to 'all' |
minLength | number | 1 | The minimum character length needed before triggering autocomplete suggestions. You can set it to 0 so suggestion are shown even when there is no text when lookup function is called. |
showHintOnFocus | boolean or "all" | false | If hints should be shown as soon as the input gets focus. If set to true, all match will be shown. If set to "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. |
scrollHeight | number, function | 0 | Number of pixels the scrollable parent container scrolled down (scrolled out the viewport). |
matcher | function | case insensitive | The method used to determine if a query matches an item. Accepts a single argument, the item against which to test the query. Access the current query with this.query. Return a boolean true if query is a match. |
sorter | function | exact match, case sensitive, case insensitive | Method used to sort autocomplete results. Accepts a single argument items and has the scope of the typeahead instance. Reference the current query with this.query. |
updater | function | returns selected item | The method used to return selected item. Accepts a single argument, the item and has the scope of the typeahead instance. |
highlighter | function | highlights all default matches | Method used to highlight autocomplete results. Accepts a single argument item and has the scope of the typeahead instance. Should return html. |
displayText | function | item.name || item | Method used to get textual representation of an item of the sources. Accepts a single argument item and has the scope of the typeahead instance. Should return a String. |
autoSelect | boolean | true | Allows you to dictate whether or not the first suggestion is selected automatically. Turning autoselect off also means that the input won't clear if nothing is selected and enter or tab is hit. |
afterSelect | function | $.noop() | Call back function to execute after selected an item. It gets the current active item in parameter if any. |
delay | integer | 0 | Adds a delay between lookups. |
appendTo | jQuery element | null | By defaut, the menu is added right after the input element. Use this option to add the menu to another div. It should not be used if you want to use bootstrap dropup or dropdown-menu-right classes. |
fitToElement | boolean | false | Set to true if you want the menu to be the same size than the input it is attached to. |
addItem | JSON object | false | Adds an item to the end of the list, for example "New Entry". This could be used, for example, to pop a dialog when an item is not found in the list of data. Example: http://cl.ly/image/2u170I1q1G3A/addItem.png |
changeInputOnSelect | boolean | true | Put the selected value text representation in the input |
changeInputOnMove | boolean | true | Put the active value text representation in the input |
openLinkInNewTab | boolean | false | Open links in a new window/tab |
selectOnBlur | boolean | true | Automatically select the active value on blur |
showCategoryHeader | boolean | true | Show categories header in the dropdown menu |
.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.To use with Bower. Add to your bower.json file:
1{ 2 "name": "MyProject", 3 "dependencies": { 4 "bootstrap3-typeahead": "git://github.com/bassjobsen/Bootstrap-3-Typeahead.git#master" 5 } 6}
An AngularJS directive for the Bootstrap 3 Typeahead jQuery plugin can be found at https://github.com/davidkonrad/angular-bootstrap3-typeahead.
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:
1// instantiate the bloodhound suggestion engine 2var numbers = new Bloodhound({ 3 datumTokenizer: Bloodhound.tokenizers.whitespace, 4 queryTokenizer: Bloodhound.tokenizers.whitespace, 5 local: ["(A)labama","Alaska","Arizona","Arkansas","Arkansas2","Barkansas"] 6}); 7 8// initialize the bloodhound suggestion engine 9numbers.initialize(); 10 11$(".typeahead").typeahead({ 12 items: 4, 13 source:numbers.ttAdapter() 14});
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:
1$("input").tagsinput({ 2 typeahead: { 3 source: ["Amsterdam", "Washington", "Sydney", "Beijing", "Cairo"] 4 } 5});
or
1$("input").tagsinput({ 2 typeahead: { 3 source: function(query) { 4 return $.get("http://someservice.com"); 5 } 6 } 7});
See also: https://github.com/bassjobsen/Bootstrap-3-Typeahead/issues/40
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 6/13 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More