_renderItem is not executing at all, tried with console.log too no messages printed. Tried with 'autocomplete', 'ui-autocomplete', 'Autocomplete' attributes no hope.
In addition I could not understand the purpose of "response with map functions", so disabled it.
$(document).ready(function () {
myVars.shId = $('#dataVar').attr('sh-data');
///// search ////// http://jsbin.com/xavatajiku/edit?js,output
console.log(myVars.shId);
$('#name-list').autocomplete({
source: function (request, response) {
$.ajax({
url: myVars.czbUrl,
data: { searchText: request.term, maxResults: 10, shopId: myVars.shId },
dataType: "json",
success: function (data) {
console.log(data);
/*response($.map(data, function (item) {
console.log(data);
return {
value: item.product_name,
avatar: item.pfimage_thumb,
rep: item.product_name,
selectedId: item.url
};
}))*/
}
})
},
select: function (event, ui) {
alert(ui.item ? ("You picked '" + ui.item.label)
: "Nothing selected, input was " + this.value);
return false;
}
}).autocomplete( "instance" )._renderItem = function (ul, item) {
console.log('test');
/*var inner_html = '<a><div class="list_item_container"><div class="image"><img src="' + item.pfimage_thumb + '"></div><div class="label"><h3> Reputation: ' + item.volume + '</h3></div><div class="description">' + item.product_name + '</div></div></a><hr/>';
return $("<li></li>")
.data("ui-autocomplete-item", item)
.append(inner_html)
.appendTo(ul);*/
};
HTML:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<h4>search:<input type="text" id="name-list" /></h4>
jquery-ui.js
afterjquery.min.js
and check if any errors in consoledata
look like? Have you checked it's being delivered as expected? Most likely therenderMenu
function is not firing because theresponse()
callback receives nothing