mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Split out logic for rendering individual items.
This commit is contained in:
parent
1402650134
commit
925bf9ec35
15
ui/jquery.ui.autocomplete.js
vendored
15
ui/jquery.ui.autocomplete.js
vendored
@ -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 );
|
||||||
|
Loading…
Reference in New Issue
Block a user