Skip to content

Commit 5e3755a

Browse files
committed
Autocomplete: Added demo of scrollable results. Fixes #5815 - Autocomplete: document and demo a scrolling menu.
1 parent 44daca1 commit 5e3755a

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

demos/autocomplete/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ <h4>Examples</h4>
1313
<li><a href="remote.html">Remote datasource</a></li>
1414
<li><a href="remote-with-cache.html">Remote with caching</a></li>
1515
<li><a href="remote-jsonp.html">Remote JSONP datasource</a></li>
16+
<li><a href="maxheight.html">Scrollable results (max-height)</a></li>
1617
<li><a href="combobox.html">Combobox</a></li>
1718
<li><a href="custom-data.html">Custom data and display</a></li>
1819
<li><a href="xml.html">XML data parsed once</a></li>

demos/autocomplete/maxheight.html

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>jQuery UI Autocomplete Scrollable Results Demo</title>
6+
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
7+
<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
8+
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
9+
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
10+
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
11+
<script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script>
12+
<link type="text/css" href="../demos.css" rel="stylesheet" />
13+
<style type="text/css">
14+
.ui-autocomplete {
15+
max-height: 100px;
16+
overflow-y: auto;
17+
}
18+
/* IE 6 doesn't support max-height
19+
* we use height instead, but this forces the menu to always be this tall
20+
*/
21+
* html .ui-autocomplete {
22+
height: 100px;
23+
}
24+
</style>
25+
<script type="text/javascript">
26+
$(function() {
27+
var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme"];
28+
$("#tags").autocomplete({
29+
source: availableTags
30+
});
31+
});
32+
</script>
33+
</head>
34+
<body>
35+
36+
<div class="demo">
37+
38+
<div class="ui-widget">
39+
<label for="tags">Tags: </label>
40+
<input id="tags" />
41+
</div>
42+
43+
</div><!-- End demo -->
44+
45+
<div class="demo-description">
46+
<p>
47+
When displaying a long list of options, you can simply set the max-height for the autocomplete menu to prevent the menu from growing too large. Try typing "a" or "s" above to get a long list of results that you can scroll through.
48+
</p>
49+
</div><!-- End demo-description -->
50+
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)