无法让Twitter Typeahead在Bootstrap中工作 [英] Can't get Twitter Typeahead to work in Bootstrap
本文介绍了无法让Twitter Typeahead在Bootstrap中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能是一个菜鸟问题,但是我无法弄清楚为什么此代码无法正常工作.仅供参考,这只是从仅有几个州的州抽出的县的示例列表.我根据较早的输入从php中提取了列表,但这不是问题,列表很好,其自动完成功能不起作用.
This might be a noob issue, but I cannot figure out why this code is not working. FYI this is just a sample list of counties pulled from a state with just a few. I pull the list from php based on earlier inputs, but that is not the issue, the list is fine, its autocomplete not working.
<div>Local County:
<input type="text" class="input-block-level required typeahead" id="county" name='county' placeholder="Local County" />
<div>
<script>
$("#county").typeahead({
local: ["Apache", "Cochise", "Coconino", "Gila", "Graham", "Greenlee", "La Paz", "Maricopa", "Mohave", "Navajo", "Pima", "Pinal", "Santa Cruz", "Yavapai", "Yuma"]
});
</script>
推荐答案
只需在JavaScript中将local
替换为source
Just replace local
by source
in your javascript
$("#county").typeahead({
source: ["Apache", "Cochise", "Coconino", "Gila", "Graham", "Greenlee", "La Paz", "Maricopa", "Mohave", "Navajo", "Pima", "Pinal", "Santa Cruz", "Yavapai", "Yuma"]
});
本地与独立的Typeahead库一起使用.
Local is used with the standalone Typeahead library.
这是更新的jsfiddle: http://jsfiddle.net/s4wx9/1/
Here's an updated jsfiddle: http://jsfiddle.net/s4wx9/1/
这篇关于无法让Twitter Typeahead在Bootstrap中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文