typeahead.js icon indicating copy to clipboard operation
typeahead.js copied to clipboard

How to count suggestions after input change?

Open phlegx opened this issue 10 years ago • 1 comments

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

phlegx avatar Aug 26 '15 12:08 phlegx

did you get this done?

odion-cloud avatar Nov 05 '23 13:11 odion-cloud