Reputation: 21
I wanted to add a default value (All) in the dropdown list of typeahead apart from the suggested value that comes up in the dropdown list when the user types some text in the typeahead textfield.
Any help on this is greatly appreciated.
Thanks
Upvotes: 2
Views: 2679
Reputation: 626
If you're using the latest version of typeahead.js for Bootstrap 3, then you can add another dataset that always returns the default value you want:
$('input').typeahead(null,
//real dataset
{
name: 'real-data',
source: backend.ttAdapter() //Your current suggestions
},
//default dataset - will always be shown in dropdown
{
name: 'default-data',
source: function(query, callback) {
callback([{value: 'All'}]);
}
}
);
See this section of the docs for more information.
Upvotes: 1