I am trying to implement jQuery autocomplete with a custom drop down menu. I am able to customize menu items with the data()._renderItem method (commented out) ,but this disables the menu "Select" functionality. If I attempt to customize menu items via the "label" field The "Select" functionality works but my menu item HTML is interpreted as a string. Can anyone suggest a clean way of accomplishing this.
$("input#selectedInput")
.bind("autocompleteselect", function (event, ui) {
alert("Sel item " + JSON.stringify(ui.item.json));
})
.autocomplete({
appendTo: "#list",
source: function (request, response) {
//alert("success");
$.ajax({
//url: "http://itunes.apple.com/search?term=jack+johnson&entity=musicTrack",
url: "Example REST URL",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function (data) {
response($.map(data.results, function (item) {
itunesJson = item;
return {
label: "<li><img src='" + item.artworkUrl30 + "' alt='no photo'/>" + item.trackName + "</li>",
}
}));
},
});
}
})
/*
.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append("<img src='"+item.value+"' alt='no photo'/>"+ item.label)
.appendTo( ul );
};
*/