]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Split out logic for rendering individual items.
authorScott González <scott.gonzalez@gmail.com>
Mon, 8 Feb 2010 01:31:10 +0000 (01:31 +0000)
committerScott González <scott.gonzalez@gmail.com>
Mon, 8 Feb 2010 01:31:10 +0000 (01:31 +0000)
ui/jquery.ui.autocomplete.js

index c6d2e5578e4f698cbc9deb03d6718251fdc3829a..78ac1f8b52c651dc7fca55aba618aed8bf30907a 100644 (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 );