I found several examples in the internet but they don't work for me though. I am trying to react on a select of a jquery ui autocomplete box. I managed to have a valid callback of results however when I click on an entry the select event is not fired. My code looks like this:
select: function( event, ui )
{
alert( ui.item.value);
}
The response come from a PHP file. I tried with a usual JSON Array with just the names of the results and after some research in the internet I changed it to an array that looks like this:
[{"id":0,"label":"Pinocchio","value":"Pinocchio"}]
But that does not work for me either. So what's wrong with it?
[edit]: In the view:
$('#search').autocomplete
({
source:
function(request, response)
{
var input = $('#search').val();
$.ajax(
{
type: 'POST',
url: '".CController::createUrl('autoComplete')."',
data:
{
string: input
},
success:
function (data)
{
response(data);
},
dataType: 'json',
select: function( event, ui ) {
alert( ui.item.value);
}
});
}
})
Yeah, the array looks like I posted above. But even if it looks like ["value1","value2"] the select event is not fired. The weird thing is that the results ARE displayed however a select has no effect. So either it's the select part of the autocomplete or the array has not the correct form. But does it need a certain form?