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 ) { _suggest: function( items ) {
var ul = this.menu.element.empty(); var self = this,
ul = this.menu.element.empty();
$.each( items, function( index, item ) { $.each( items, function( index, item ) {
$( "<li></li>" ) self._renderItem( ul, item );
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
}); });
this.menu.refresh(); this.menu.refresh();
this.menu.element.show(); 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 ) { _move: function( direction, event ) {
if ( !this.menu.element.is(":visible") ) { if ( !this.menu.element.is(":visible") ) {
this.search( null, event ); this.search( null, event );