Autocomplete: Split out logic for rendering individual items.

This commit is contained in:
Scott González 2010-02-08 01:31:10 +00:00
parent 1402650134
commit 925bf9ec35

View File

@ -235,12 +235,10 @@ $.widget( "ui.autocomplete", {
},
_suggest: function( items ) {
var ul = this.menu.element.empty();
var self = this,
ul = this.menu.element.empty();
$.each( items, function( index, item ) {
$( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
self._renderItem( ul, item );
});
this.menu.refresh();
this.menu.element.show();
@ -249,6 +247,13 @@ $.widget( "ui.autocomplete", {
}
},
_renderItem: function( ul, item) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
},
_move: function( direction, event ) {
if ( !this.menu.element.is(":visible") ) {
this.search( null, event );