typeahead 0.11.1 ttl不起作用

时间:2015-05-23 20:48:28

标签: typeahead.js bootstrap-typeahead twitter-typeahead

我正在使用typeahead 0.11.1,即使我在Bloodhound中将TTL设置为1,也不会更新自动填充的选项列表。这在v0.10中运行良好。

另一种让typeahead / Bloodhound重新加载选项的方法是什么? 这是我使用的代码

var WhtTypeahead = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('pureName'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    //limit: 999, //removed in typeahead 0.11.* 
    prefetch: {
        ttl: 1, //to expire the cache
        url: '/Customers/getCustomers/',
        dataType: "jsonp",
        filter: function (toursAndTemplates) {
            ..returns a JSON here..
        }
})


$('#nameInput').typeahead(
   {
       hint: true,
       highlight: true,
       minLength: 0,
   },
   {
      limit:999, //limit from bloodhound has been moved here in v.0.11.*
      name: 'toursAndTemplates',
      displayKey: 'pureName', //what to show in textbox
      //valueKey: 'pureName',  //the actual value of the textbox (not shown in it)
      source: WhtTypeahead.ttAdapter(),
      templates: { //below is the part that uses handlebars
          empty: [
          '<div class="empty-message">',
          'Type template/tour name',
          '</div>'
          ].join('\n'),
          suggestion: Handlebars.compile(
              '<p><strong>{{pureName}}</strong>{{datesAsSuffix}}</p>'
              )
      }

  }

0 个答案:

没有答案