Why is the autocomplete
executed every time I press a key?
This is the code used:
$('#xmarcaId').autocomplete({
source: "productosServices17.html?opcion=PRUEBA",
minLength:1,
select: function(event, ui){
// just in case you want to see the ID
var accountVal = ui.item.value;
console.log(accountVal);
// now set the label in the textbox
var accountText = ui.item.label;
$('#xmarcaId').val(accountText);
return false;
},
focus: function( event, ui ) {
// this is to prevent showing an ID in the textbox instead of name
// when the user tries to select using the up/down arrow of his keyboard
$( "#xmarcaId" ).val( ui.item.label );
return false;
}
});