.ui-autocomplete {
max-height: 100px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
/* add padding to account for vertical scrollbar */
padding-right: 20px;
}
/* IE 6 doesn't support max-height
* we use height instead, but this forces the menu to always be this tall
*/
* html .ui-autocomplete {
height: 100px;
}
JavaScript
$(function () {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme",
"AA",
"BB",
"CC",
"DD",
"EE",
"FF",
"GG",
"HH",
"II",
"JJ",
"KK"
];
$.extend($.ui.autocomplete.prototype, {
_renderMenu: function (ul, items) {
//remove scroll event to prevent attaching multiple scroll events to one container element
$(ul).unbind("scroll");
var self = this;
self._scrollMenu(ul, items);
},
_scrollMenu: function (ul, items) {
var self = this;
var maxShow = 5;
var results = [];
var pages = Math.ceil(items.length / maxShow);
results = items.slice(0, maxShow);
if (pages > 1) {
$(ul).scroll(function () {
if (isScrollbarBottom($(ul))) {
++window.pageIndex;
if (window.pageIndex >= pages) return;
results = items.slice(window.pageIndex * maxShow, window.pageIndex * maxShow + maxShow);
//append item to ul
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.