简体   繁体   English

远程远程引导提前无法正常工作

[英]Remote bootstrap typeahead not working

I have a form with a category dropdown (with options Gems, Programming Languages, Databases etc.) and a textfield that should be autocomplete based on query from the server side. 我有一个带有类别下拉列表的表单(带有选项Gems,Programming Languages,Databases等)和一个文本字段,该文本字段应根据服务器端的查询自动完成。 My code is working till the ajax call as its returning the correct result set as JSON response. 我的代码一直工作到ajax调用返回正确的结果集作为JSON响应。 But the autocomplete drop down is not showing. 但是自动填充下拉列表没有显示。

$(document).ready(function() {
    var bestPictures = new Bloodhound({
    datumTokenizer: function (d) { 
      return Bloodhound.tokenizers.whitespace(d.value)},
      queryTokenizer: Bloodhound.tokenizers.whitespace,
      remote: { 
       url: '/typeahead',
       replace: function(url, uriEncodedQuery) {
        var categoryID = $('#user_skills_attributes_1_category_id').val();
     return url + "?q="+uriEncodedQuery+ "&category_id=" + encodeURIComponent(categoryID)
  }
 }
});

bestPictures.initialize();

$('#user_skills_attributes_1_name').typeahead({highlight: true}, {
  name: 'best-pictures',
  display: 'value',
  source: bestPictures.ttAdapter()
});
 })

I also came across such issue. 我也遇到过这样的问题。 Try using a lower version of typeahead. 尝试使用较低版本的预输入。 It might solve your issue. 它可能会解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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