Reputation: 491
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>
Upvotes: 1
Views: 4128
Reputation: 3252
It works to me. Run this Code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.1/bootstrap3-typeahead.min.js"></script>
<div>Cnty:
<input type="text" class="input-block-level required typeahead" id="county" name='county' placeholder="Local County" />
<div>
<script>
$("#county").typeahead({
source: ["Apache", "Cochise", "Coconino", "Gila", "Graham", "Greenlee", "La Paz", "Maricopa", "Mohave", "Navajo", "Pima", "Pinal", "Santa Cruz", "Yavapai", "Yuma"]
});
</script>
Include:These above
jquery-2.1.1.min.js
bootstrap.min.css
bootstrap.min.js
You are done. Thanks.
Upvotes: 0
Reputation: 6769
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"]
});
Local is used with the standalone Typeahead library.
EDIT: Here's an updated jsfiddle: http://jsfiddle.net/s4wx9/1/
Upvotes: 2
Reputation: 388316
There are two problems
try
$("#county").typeahead({
source: ["Apache", "Cochise", "Coconino", "Gila", "Graham", "Greenlee", "La Paz", "Maricopa", "Mohave", "Navajo", "Pima", "Pinal", "Santa Cruz", "Yavapai", "Yuma"]
});
Demo: Fiddle
Upvotes: 1