您好我是Typeahead的新手,我尝试使用Bloodhound和Typeahead加载自动搜索,但我没有得到任何搜索结果。
**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>
这里我没有获得自动完成选项 这是我的第一个演示,因此无法理解我是否在Bloodhound.js中犯了错误,或者必须调整我从gifthub网站下载的typeahead.js