Created
August 29, 2012 19:44
-
-
Save bshyong/3517822 to your computer and use it in GitHub Desktop.
Jquery UI autocomplete example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ui.autocomplete, { | |
_renderMenu: function( ul, items ) { | |
// use this to manipulate the entire array of results | |
// if you overwrite this method, make sure to call _renderItem for each item | |
// or else the individual items will not render, only the menu will render | |
// example below. | |
var self = this; | |
$.each(items, function(index, item){ | |
self._renderItem(ul, item); | |
} | |
}, | |
_renderItem: function(ul, item){ | |
// use this to specify how your autocomplete results are rendered | |
// example below. note you need to use the data method | |
// otherwise the object's attributes will not be sent with the object when it is rendered. | |
return $( "<li></li>" ) | |
.data( "item.autocomplete", item ) | |
.append( "<a>" + item.label + "</a>" ) | |
.appendTo( ul ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment