1
I got the following script
autocomplete:
$(document).ready(function () {
$("#id_cliente").autocomplete({
source: function (request, response) {
$.ajax({
url: "/PreVenda/CarregaClientePorId",
type: "POST",
dataType: "json",
data: { id: request.term },
success: function (data) {
response($.map(data, function (item) {
return {
label: item.id,
value: item.id,
id: item.nome_razao
};
}))
}
})
}, select: function (event, ui) {
console.log(ui)
$("#nome_cliente").val(ui.item.id);
},
messages:
{
noResults: "", results: ""
}
});
})
That one script
, when informing the client’s ID, a list of Ids is loaded, and when selecting the desired ID, the client’s name is filled in. He’s doing it right, but by selecting once, I can’t click to select again. I can only select again if I press the down or up keys and press the ENTER key. I cannot select when clicking with the mouse, and the following error appears:
Uncaught Typeerror: Cannot read Property 'call' of Undefined
I wonder what I’m doing wrong in the autocomplete, to be able to click and select more than once.
Change the ready trigger to click + autocomplete input
– AnthraxisBR
Buddy, it didn’t work out
– Alysson bormann
I would have to post the HTML in the question for us to try to reproduce the problem. Why is it weird. Maybe I’m giving some conflict with another code.
– Sam