键入时jQuery自动完成不显示结果

时间:2018-03-01 11:39:29

标签: jquery autocomplete

我正在动态列表中创建自动填充功能。它正在工作但不显示控制台日志中显示的结果和数据。

当我开始输入时,输入字段显示控制台日志,所有列表显示此但不显示。

HTML:

<input type='text'
    class='btnText' 
    id="symptomSearch" 
    tabIndex='1' 
    placeholder='Type words to search from repertory' onkeydown="SearchForResult(this,'RepSearch')"
    oninput="SearchSuggestionAutocom()"/>

jQuery的:

function SearchSuggestionAutocom() {
    console.log(getData(cust_list.library.search.searchSuggetionWord,["12","a"]));
    var availablesearchSuggetion = JSON.parse(getData(cust_list.library.search.searchSuggetionWord,["12", $("#symptomSearch").text()]))

    $( "#symptomSearch" ).autocomplete({
        maxLength   : 5,
        source      : availablesearchSuggetion.suggestions.split(',')
    });
};

1 个答案:

答案 0 :(得分:0)

jQuery.autocomplete中没有maxLength属性。

试试这个:

$("#symptomSearch").autocomplete({
    source: availablesearchSuggetion.suggestions.split(',').slice(0, 5)
});

此外,您有多个拼写错误:

  

searchSuggetionWord = searchSugge s tionWord

cust_list.library.search.searchSuggestionWord,["12","a"];

  

availablesearchSuggetion = availablesearchSugge s tion

var availablesearchSuggestion...
availablesearchSuggestion.suggestions.split(',')

请注意添加的 s