-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery-autocomplete.html
54 lines (40 loc) · 1.34 KB
/
jquery-autocomplete.html
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
53
54
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Fast n' Fuzzy - jQuery Autocomplete integration demo</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script src="../dist/fast-n-fuzzy.min.js"></script>
</head>
<body>
<label for="autocomplete">Select a country:</label>
<input id="autocomplete">
<script>
var countriesMap = new StringMap();
// Load country names asynchronically
$.ajax("countries.json", {
type: "get",
dataType: "json",
success: function(countries){
// Add entries to the map for every country
var country;
for(var i = 0; i < countries.length; i++){
country = countries[i];
countriesMap.add(country, country);
}
// Setup autocomplete component
$("#autocomplete").autocomplete({
source: function(request, response) {
// Perform search
var results = countriesMap.search(request.term);
// Return results
response(results);
}
});
}
});
</script>
</body>
</html>