Skip to content

Instantly share code, notes, and snippets.

@crussell52
Created August 25, 2010 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crussell52/549839 to your computer and use it in GitHub Desktop.
Save crussell52/549839 to your computer and use it in GitHub Desktop.
borrowing heavily from http://github.com/scottgonzalez/jquery-ui-extensions/blob/master/autocomplete/jquery.ui.autocomplete.html.js, this extension adds support for a callback function for building the text of the item label.
(function ( $ )) {
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
var text = (this.options.label) ? this.options.label( item ) : item.label;
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( text );
.appendTo( ul );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment