键入第一个字母时,Typeahead不起作用

时间:2015-03-12 09:34:55

标签: javascript css twitter-bootstrap typeahead

在我的java脚本中,我尝试显示typeahead。它不会显示输入第一个字母的国家/地区,但是当我输入第二个字母时它会显示。

我的脚本是

 $('#country_v1-query').typeahead({
            order: "desc",            
            source: {
                data: [
                    "Afghanistan", "Albania", "Algeria", "Andorra", "Angola",  "Ukraine", "United Arab Emirates", "United Kingdom", "United States",  "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"
                ]
            },
            callback: {
                onInit: function (node) {
                    console.log('Typeahead Initiated on ' + node.selector);
                }
            }
        });

我用这样的id

来调用脚本
 <input type="text" id="country_v1-query" name="country_v1[query]" autocomplete="on" class=" typeahead" data-provide="typeahead"  />

包含链接 typeahead.js, typeahead.css, jquery-ui.js, jquery-ui.css, bootstrap.min.css

1 个答案:

答案 0 :(得分:0)

我得到了答案,我在我的脚本中插入了minLength: "1",