When I try to implement auto-complete using the code below I get an error stating:
.data("autocomplete") is undefined
How ever if I remove the .data() method from the end it works fine (just with out the customizable graphics that .data() provides). Can anyone tell me what's going wrong?
$("input#testInput").bind("autocompleteselect", function (event, ui) {
}).autocomplete({
appendTo: "#autoCompList",
source: function (request, response) {
$.ajax({
url: JSONP CALL URL
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function (data) {
response($.map(data.data, function (item) {
fbPageJson = item;
return {
label: item.name,
image: item.picture,
json: item,
}
}));
},
});
}
}).data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>").data("item.autocomplete", item).append("<a><img src='" + item.image + "' alt='no photo'/></a>" + item.label).appendTo(ul);
};