Closed
Description
Hi there,
Great code here - love this typeahead. I have everything working, but just cannot for the life of me get the results to show the "no results found" message. This is what I am currently using:
$('#q').typeahead({
minLength: 2,
maxItem: 8,
order: "asc",
backdrop: {
"background-color": "#eaeaea"
},
delay: 300,
source: {
project: {
url: [{
type: "POST",
url: "/json/locations.asp",
data: {
q: "{{query}}"
}
}, "data.locations"],
display: "locname",
template: '<div>' +
' <span class="lname">{{locname}}</span>' +
' <span class="laddress">({{addr}})</span>' +
"</div>"
},
},
templates: {
empty: '<div class="empty-message">No matches.</div>'
},
callback: {
onResult: function(node, query, obj, objCount) {
var text = "";
if (query !== "") {
text = objCount + ' elements matching "' + query + '"';
}
//$('#result-container').text(text);
},
onClick: function(node, a, obj, e) {
alert(JSON.stringify(obj));
alert(obj.id);
}
},
debug: true
});
I am not getting any errors, so maybe it is a CSS issue and the message is being hidden? The only other way I wanted to try was to append an item to the list that was NOT filtered out. Icould obviously add to the search results, but if the search criteria entered does not exist in "no results found" it does not show.
Sorry for the long question. Any help would be greatly appreciated! If this is a bug, please let me know a workaround. If not, are there any examples / demos with the empty template I can check out?
Thank you!
Dennis