Javascript 具有多个远程数据源的typeahead/Hound

Javascript 具有多个远程数据源的typeahead/Hound,javascript,typeahead.js,Javascript,Typeahead.js,我想使用twitter的typeahead实现搜索自动建议。此autosuggest应提供术语建议(术语)和产品建议(产品)。这两个建议都可以远程检索。然而,typeahead方法似乎只调用一个远程URL。第二个永远不会被调用 有人知道我做错了什么吗?这是我的密码: $(document).ready(function () { var termEngine = new Bloodhound({ name: 'searchTerms', remote: "/index.php

我想使用twitter的typeahead实现搜索自动建议。此autosuggest应提供术语建议(术语)和产品建议(产品)。这两个建议都可以远程检索。然而,typeahead方法似乎只调用一个远程URL。第二个永远不会被调用

有人知道我做错了什么吗?这是我的密码:

$(document).ready(function () {
  var termEngine = new Bloodhound({
    name: 'searchTerms',
    remote: "/index.php?terms=true&g=%QUERY",
    datumTokenizer: Bloodhound.tokenizers.whitespace,
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    cache: false
  });
  var productEngine = new Bloodhound({
    name: 'products',
    remote: "/index.php?products=true&g=%QUERY",
    datumTokenizer: Bloodhound.tokenizers.whitespace,
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    cache: false
  });

  termEngine.initialize();
  productEngine.initialize();

  $('#searchField').typeahead(
      {
        name: 'searchTerms',
        source: termEngine.ttAdapter()
      }, {
        name: 'products',
        source: productEngine.ttAdapter()
  });
}

我还添加了一个具有相同问题的JSFIDLE链接(尽管是不同的远程数据源):

问题已经解决:我必须向typeahead方法添加一个空选项对象:

$('#searchField').typeahead({},
  {
    name: 'searchTerms',
    source: termEngine.ttAdapter()
  }, {
    name: 'products',
    source: productEngine.ttAdapter()
});
这样可以确保两个请求都得到执行