You left out an important part of the custom _renderMenu function, or perhaps are using one that goes with an older version of the UI. Replace:
Code:
$.ui.autocomplete.prototype._renderMenu = function( ul, items ) {
var self = this;
$.each( items, function( index, item ) {
if (index < 10) // here we define how many results to show
{self._renderItem( ul, item );}
});
}
with
Code:
$.ui.autocomplete.prototype._renderMenu = function( ul, items ) {
var that = this;
$.each( items, function( index, item ) {
if (index < 10) // here we define how many results to show
{that._renderItemData( ul, item );}
});
}
The use of that instead of self as a variable name is probably minor but 'self' could confuse some browsers, it's synonymous with window and this in the global scope and because of that may even be reserved in some browsers. The important change is _renderItemData. Without that you get the error.
And doing it like so:
Code:
$.ui.autocomplete.prototype._renderMenu = function( ul, items ) {
var that = this;
$.each( items, function( index, item ) {
if (index > 9) {return false;} // here we define how many results to show
that._renderItemData( ul, item );
});
}
would be more efficient because it stops looping as soon as 10 matches are found.
Bookmarks