typeahead.js
typeahead.js copied to clipboard
How to count suggestions after input change?
Hi!
How can I count all suggestions in the view after input has changed? I want to see if the input matches the single available suggestion.
$(document).ready(function() {
var states = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "/search/%QUERY.json",
wildcard: '%QUERY'
}
});
$('#bloodhound .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
} , {
name: 'states',
source: states,
display: 'value'
}).on('input', function(e, data) {
/* Input has changed. Are suggestions present? If yes how many? */
});
});
How can I code this? Any idea?
Bye
did you get this done?