Bootstrap-3-Typeahead
Bootstrap-3-Typeahead copied to clipboard
how display no result found
if the user write a wrong word , we must displayed "no result found"
It is better if you have any code for me to look at because I'm using ajax in the source part, yours might differ but anyway here's my solution. If you have any question in stackoverflow let me know, I want to gain some reputation :)
$('#inputName').typeahead({
source: function (query,process) {
$.ajax({
url: 'action.php',
data: {'key':'',q: query},
dataType: 'json'
}).done(function(data) {
if(data.length<=0){
// Display no result found
}
return process(data); // <-- Do not ever try to put this at the 'else' statement, your hint box will be stucked
});
}
});