-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbloodhound.html
More file actions
52 lines (41 loc) · 1.16 KB
/
bloodhound.html
File metadata and controls
52 lines (41 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
header bitch
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="file:///Users/elessar0x3/dev/app_academy/bookfriends/vendor/assets/javascripts/typeahead.bundle.js"></script>
</head>
<body>
<div id="bloodhound">
<input class="typeahead" type="text" placeholder="States of USA">
</div>
</body>
</html>
<script>
var searchSuggestions = [
"math",
"apple",
"fuji"
];
var engine = 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(searchSuggestions, function(state) { return { value: state }; })
});
// kicks off the loading/processing of `local` and `prefetch`
engine.initialize();
$('#bloodhound .typeahead').typeahead({
// $('#bloodhound-search-area .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: engine.ttAdapter()
});
</script>