Saturday, December 20, 2014

jQuery UI Autocomplete Changes in 1.10

Legacy 1.9 Code:
$("#searchBox").data("uiAutocomplete")._renderItem = function (ul, item) {
 return renderAutoCompleteItems(ul, item);
};

renderAutoCompleteItems = function(ul, item) {
 return $("<li />")
   .data("item.autocomplete", item)
   .append("<a><img style='width:50px; height:50px;' src='" + item.icon + "' /> " + item.label + "</a>")
   .appendTo(ul);
};

Updated 1.10 Code:
$("#searchBox").data("ui-autocomplete")._renderItem = function (ul, item) {
 return renderAutoCompleteItems(ul, item);
};

renderAutoCompleteItems = function(ul, item) {
 return $("<li />")
   .data("ui-autocomplete-item", item)
   .append("<a><img style='width:50px; height:50px;' src='" + item.icon + "' /> " + item.label + "</a>")
   .appendTo(ul);
};

No comments: