寻血猎犬限制不起作用



我使用以下代码在输入字段上启用 typeahead有时区域不显示,但是当我在检查元素中看到"网络 XHR 请求"时。URL 确实返回数据。

限制在此示例中不起作用的另一个问题。 我尝试了不同的数字,但没有一个有效

var Regions = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('label'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: {
        url: 'https://www.domain.com/getcities?query=%QUERY',wildcard: '%QUERY'
    },
    limit: 10
});
Regions.initialize();
var hotels = new Bloodhound({
    datumTokenizer: function (datum) {
        return Bloodhound.tokenizers.whitespace(datum.value);
    },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: {
        url: 'https://www.domain.com/gethotels?query=%QUERY',
         wildcard: '%QUERY', 
    },
    limit: 10
});
hotels.initialize();
function typeAhead()
{

$('#myinput').typeahead({
      hint: true,
      highlight: true,
      minLength: 2
},
{
  name: 'nba-teams',
  displayKey: 'label',
  source: Regions.ttAdapter()  ,
  templates: {
    header: '<h3 class="league-name">Cities and regions</h3>'
  }
},
{
  name: 'nhl-teams',
   displayKey: 'label',
  source: hotels.ttAdapter()  ,
  templates: {
    header: '<h3 class="league-name">Hotels</h3>'
  }
});

}

请检查以下代码。

var Regions = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('label'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: {
        url: 'https://www.domain.com/getcities?query=%QUERY',wildcard: '%QUERY'
    }
});
Regions.initialize();
var hotels = new Bloodhound({
    datumTokenizer: function (datum) {
        return Bloodhound.tokenizers.whitespace(datum.value);
    },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: {
        url: 'https://www.domain.com/gethotels?query=%QUERY',
        wildcard: '%QUERY', 
    }
});
hotels.initialize();
function typeAhead(){
    $('#myinput').typeahead({
            hint: true,
            highlight: true,
            minLength: 2
        },
        {
            name: 'nba-teams',
            displayKey: 'label',
            source: Regions.ttAdapter()  ,
            limit: 10,
            templates: {
                header: '<h3 class="league-name">Cities and regions</h3>'
            }
        },
        {
            name: 'nhl-teams',
            displayKey: 'label',
            source: hotels.ttAdapter()  ,
            limit: 10,
            templates: {
            header: '<h3 class="league-name">Hotels</h3>'
        }
    });
}

相关内容

  • 没有找到相关文章

最新更新