0

嗨,我是 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()
});    

索引.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

4

0 回答 0