I have the jQuery UI Autocomplete setup to my liking and working perfectly, but there is one fatal flaw. In my autocomplete I use a custom display like this example. I hav
The only way I can make this work is by changing my code from:
addautocomplete($('.tagEntry'));
To:
$('.tagEntry').each(function() {
addautocomplete(this);
});
Alternatively:
$(..).autocomplete(..).each(function () {
$.data(this, "autocomplete")._renderItem = function (ul, item) { ... } })
You simply need to override the function via the object prototype, instead of on a single instance.
$.ui.autocomplete.prototype._renderItem = function( ul, item ) {
return $( '<li></li>' )
.data( 'item.autocomplete', item )
.append( '<a>' + item.label + '<br/><small>' + item.desc + '<small></a>' )
.appendTo( ul );
};
Overwrite the function before activating any autocompletes, but after the script has loaded.