I am using jQuery jquery-1.10.2 and jQuery ui 1.11.4
Here is the autocomplete function :
$("#txtPOI").autocomplete({
source: function(request, response) {
$.ajax({
url: '<?php echo site_url("crowd/get_POIs") ?>',
data: {cat: selectedCode, q: request.term},
dataType: "json",
type: "post",
success: function(data) {
response( $.map( data, function( item )
{
return{
label: item.title,
value: item.title,
contentid: item.contentid,
latitude: item.latitude,
longitude: item.longitude
}
}));
},
fail : function ( jqXHR, textStatus, errorThrown ) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
},
select: function( event, ui ) {
$("#txtPOI").val(ui.item.latitude);
alert('selected');
/*
alert(ui.item.contentid);
log( ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.title);
alert(ui.item.value);
*/
},
open: function(event, ui) {
$(".ui-autocomplete").css("z-index", 1000);
},
minLength: 3
});
}
});
The ajax response successfully returned data from database. However when I tried to do something inside the select nothing happened, it seems that the select is not triggered. I would like to get the value of ui.item.contentid as well as ui.item.latitude and ui.item.longitude upon the selection of the autocomplete item.
Why the select event is not triggered ? How to solve this issue ?