I have this code in my script:
$(function() {
$( "#products" ).autocomplete({
source: "<?php echo $this->baseUrl ?>/loyalty/autocomplete",
minLength: 2,
focus: function( event, ui ) {
$( "#products" ).val( ui.item.label );
return false;
},
select: function( event, ui ) {
$("#sel_products").html($("#sel_products").html()+"<tr><td>"+ui.item.value+"</td><td>"+ui.item.id+"</td></tr>");
return false;
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( item.value)
.appendTo( ul );
};
});
The ajax result that autocomplete gets is something like this:
[{label:"Label1",value:"Value1",id:"1"},{label:"Label2",value:"Value2",id:"2"}]
The problem is that my autocomplete list is not created. Nothing happens when I start typing letters, except for ajax being returned. Btw, when I use regular non-custom data, I get the list.
What can be the problem here?