0

Hi I am new to Typeahead and I tried to simply load auto search using Bloodhound and Typeahead but I am not getting any search results.

**bloodhound.js** 
var state=['Bihar','Bengal','Orissa','Jharkhand','Delhi','Daman & Diu'];
// constructs the suggestion engine
var states = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
// `states` is an array of state names defined in "The Basics"
local: $.map(states, function(state) { return { value: state }; })
});

// kicks off the loading/processing of `local` and `prefetch`
states.initialize();

$('#bloodhound .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'states',
displayKey: 'value',
// `ttAdapter` wraps the suggestion engine in an adapter that
// is compatible with the typeahead jQuery plugin
source: states.ttAdapter()
});    

Index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Auto Complete</title>
<script type="text/javascript" src="js/typeahead.js"></script>
<script type="text/javascript" src="js/bloodhound.js"></script>
</head>
<body>
<div id="bloodhound">
States :<input type="text" id="my-input" class="typeahead"                                                                   placeholder="States Of India">
</div>
</body>
</html>

Here I am not getting the Auto Complete Options It's my first demo so unable to understand whether I am making mistake in Bloodhound.js or will have to tweak the typeahead.js which I have downloaded from the gifthub site

bhawi
  • 1
  • 1
  • In line 1, array is declared as `state` (singular) and in bloodhound `local:` array is being referred as `states` (plural) – Dhiraj Apr 04 '15 at 02:22
  • @Dhiraj Bodicherla: Even after changing the array to states (plural) there's no Impact, what else can be the reason ? – bhawi Apr 04 '15 at 13:31

0 Answers0