I have the following code:
container.autocomplete({
minLength: 2,
source: function(request, response) {
$.ajax({
type : 'POST',
url: HOST + "/lib/gets/getjsonclients.php",
dataType: "json",
data: {
q: request.term
},
success: function(data) {
ajaxCache[cachedTerm] = data;
response($.map(data, function(item) {
return {
label: item.value,
value: item.value
}
}));
}
});
},
select: function(event, ui) {
alert(ui.item.value);
this.close
},
//change: function(event, ui) {
// alert($(this).val());
//},
open: function() {
},
close: function() {
}
});
I want to catch the enter key event when I type a new value (other that which I already have in my select list).
I have tried using the .result event but I have an error: Uncaught TypeError: Object # has no method 'result' using the code:
container.result(function(event, data, formatted) {
alert($(this).val());
});
The change: event is working OK but is fired only after I loose the focus on autocomplete and I need it to be done when I hit the enter key
Thank you for your answers.