-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypeahead.html
More file actions
40 lines (37 loc) · 1002 Bytes
/
typeahead.html
File metadata and controls
40 lines (37 loc) · 1002 Bytes
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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>TypeAhead</title>
</head>
<body>
<div id="custom-templates">
<input class="typeahead" type="text" placeholder="Type in your course">
<input class="typeahead" type="text" placeholder="Type in your course">
</div>
<script src="handlebars.js"></script>
<script src="jquery.js"></script>
<script src="typeahead.js"></script>
<script>
var courses = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('tokens'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '/data.php'
});
$('#custom-templates .typeahead').typeahead(null, {
name: 'course-code',
display: 'course',
limit: 10,
source: courses,
templates: {
empty: [
'<div class="empty-message">',
'unable to find any Best Picture winners that match the current query',
'</div>'
].join('\n'),
suggestion: Handlebars.compile('<div><strong>{{course}}</strong> - {{title}}</div>')
}
});
</script>
</body>
</html>