简体   繁体   中英

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?

不幸的是,目前看来这还不可能。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM