You can expand the widget's autocomplete plugin and add a custom title to the autocomplete list by overriding the _ function renderMenu.
Code (with local data):
$(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"];
$.widget("custom.autocompleteheader", $.ui.autocomplete, {
_renderMenu: function (ul, items) {
var self = this;
$.each(items, function (index, item) {
self._renderItem(ul, item);
if (index == 0) ul.prepend('<li class="header-auto"> Header for autocomplete!!</li>');
});
}
});
$("#tags").autocompleteheader({
source: availableTags
});
});
Link: http://api.jqueryui.com/jQuery.widget/
Demo: http://jsfiddle.net/IrvinDominin/rMkER/
source
share