This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
local_complex.html
executable file
·88 lines (69 loc) · 4.19 KB
/
local_complex.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<title>jQM Autocomplete</title>
<meta content="initial-scale=1, maximum-scale=1, user-scalable=0" name="viewport" />
<meta name="viewport" content="width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="styles.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="jqm.autoComplete-1.5.2-min.js"></script>
<script src="code.js"></script>
</head>
<body>
<div data-role="page" id="mainPage">
<div data-role="header">
<h1>jQM Autocomplete</h1>
<div>
<select id="examples" data-mini="true" data-native-menu="false">
<option value="index.html">Remote Array</option>
<option value="complex.html">Remote Object</option>
<option value="array.html">Local Array</option>
<option value="local_complex.html" selected="true">Local Object</option>
<option value="callback.html">Callback</option>
<option value="callback-plus.html">Callback Plus</option>
<option value="search.html">Using Search Input</option>
</select>
</div>
</div>
<div data-role="content">
<h3>Local Complex Data</h3>
<p>
In this example autoComplete returns an array of objects from a local variable, each with a label and a value key.
</p>
<pre>
[
{
value: "22",
label: "Maine"
},
{
value: "23",
label: "Maryland"
}
]
</pre>
<p>
<input type="text" id="searchField" placeholder="Categories">
<ul id="suggestions" data-role="listview" data-inset="true"></ul>
</p>
<p>
<a href="https://github.com/commadelimited/autoComplete.js" data-role="button">Download the code</a>
</p>
</div>
</div>
<script>
$("#mainPage").bind("pageshow", function(e) {
autocompleteData = $.parseJSON('[{"value":"1.0","label":"Alabama"},{"value":"2.0","label":"Alaska"},{"value":"3.0","label":"American Samoa"},{"value":"4.0","label":"Arizona"},{"value":"5.0","label":"Arkansas"},{"value":"6.0","label":"California"},{"value":"7.0","label":"Colorado"},{"value":"8.0","label":"Connecticut"},{"value":"9.0","label":"Delaware"},{"value":"10.0","label":"District of Columbia"},{"value":"11.0","label":"Florida"},{"value":"12.0","label":"Georgia"},{"value":"13.0","label":"Guam"},{"value":"14.0","label":"Hawaii"},{"value":"15.0","label":"Idaho"},{"value":"16.0","label":"Illinois"},{"value":"17.0","label":"Indiana"},{"value":"18.0","label":"Iowa"},{"value":"19.0","label":"Kansas"},{"value":"20.0","label":"Kentucky"},{"value":"21.0","label":"Louisiana"},{"value":"22.0","label":"Maine"},{"value":"23.0","label":"Maryland"},{"value":"24.0","label":"Massachusetts"},{"value":"25.0","label":"Michigan"},{"value":"26.0","label":"Minnesota"},{"value":"27.0","label":"Mississippi"},{"value":"28.0","label":"Missouri"},{"value":"29.0","label":"Montana"},{"value":"30.0","label":"Nebraska"},{"value":"31.0","label":"Nevada"},{"value":"32.0","label":"New Hampshire"},{"value":"33.0","label":"New Jersey"},{"value":"34.0","label":"New Mexico"},{"value":"35.0","label":"New York"},{"value":"36.0","label":"North Carolina"},{"value":"37.0","label":"North Dakota"},{"value":"38.0","label":"Northern Marianas Islands"},{"value":"39.0","label":"Ohio"},{"value":"40.0","label":"Oklahoma"},{"value":"41.0","label":"Oregon"},{"value":"42.0","label":"Pennsylvania"},{"value":"43.0","label":"Puerto Rico"},{"value":"44.0","label":"Rhode Island"},{"value":"45.0","label":"South Carolina"},{"value":"46.0","label":"South Dakota"},{"value":"47.0","label":"Tennessee"},{"value":"48.0","label":"Texas"},{"value":"49.0","label":"Utah"},{"value":"50.0","label":"Vermont"},{"value":"52.0","label":"Virgin Islands"},{"value":"51.0","label":"Virginia"},{"value":"53.0","label":"Washington"},{"value":"54.0","label":"West Virginia"},{"value":"55.0","label":"Wisconsin"},{"value":"56.0","label":"Wyoming"}]');
$("#searchField").autocomplete({
target: $('#suggestions'),
source: autocompleteData,
link: 'target.html?term=',
minLength: 1
});
});
</script>
</body>
</html>