Now that Bootstrap has dropped typeahead, they are recommending the native twitter typeahead (0.9.3 at the time of this writing)
I am having trouble finding examples of how to prompt the user when there are no results found.
In the native bootstrap, you could do this : http://bootply.com/61459
Perhaps this functionality is not possible?
The typeahead input fields are very popular in modern web forms. The main purpose of using typeahead is to improve the user experience by supplying hints or a list of possible choices based on the text they've entered while filling a form or searching something — like the Google instant search.
To help a user make a selection in a long list, a dropdown typeahead shows suggestions as soon as the user starts typing.
How about something like this?
$(document).ready(function() {
$("#search").typeahead([
{
limit: 10,
remote: {
url: "//my.tld/gimmesomejson.php?searchuser=%QUERY",
filter: function(parsedResponse) {
var dataset = [];
for (i = 0; i < parsedResponse.length; i++) {
dataset.push({
value: parsedResponse[i].value,
tokens: parsedResponse[i].tokens
});
}
if (parsedResponse.length == 0) {
dataset.push({
value: "No results"
});
}
return dataset;
},
},
template: '<p>{{value}}</p>',
engine: Hogan
}
]);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With