Search code examples
javascripttypeahead.jstwitter-typeahead

Typeahead.js - how enable autocomplete for each word?


I have input of email - TO: field. This field can contain multiple emails. Right now I use such code for autocomplete (I use typeahead.js 0.11.1):

var email_autocomplete_engine = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  limit: 10,
  prefetch: {
    cache: false,
    url: "/users/" + current_user_id + "/contacts",
    filter: function(list) {
      return $.map(list, function(tag) {
        return {
          name: tag
        };
      });
    }
  }
});

email_autocomplete_engine.initialize();

$("#email_to").typeahead(null, {
  name: 'account_media_contents',
  displayKey: 'name',
  source: email_autocomplete_engine.ttAdapter()
});

Problem is that it doesn't work when user select first email and print space and first letter of email. But since I can have many emails I want to be able to show autocomplete options for second/third/etc emails too! Any way to do that?


Solution

  • Okay unfortunately in the present time it doesn't seem to be possible.