Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get selected option jquery autocomplete [duplicate]

I know there's a "select" event but is not working.

This is my code:

$("#Asignacion_Movimiento_OrdenCompra").autocomplete(
        "/Asignaciones/ObtenerOrdenesCompra",
        {
            extraParams: { Serial: function () { return $("#Asignacion_Movimiento_Material").val(); } },
            delay: 200,
            select: function (event, ui) {
                alert(this.value + " - " + ui.item.value);
                ObtenerDatosAdicionales();
                return true;
            }
        }
    );

I also tried adding:

result: function (event, data, formatted) {
                alert(data);
                ObtenerDatosAdicionales();
                return true;
            }

But nothing happens...

How can I get the value of the selected item by the user?

Thx.

like image 227
tina Avatar asked Jan 13 '11 20:01

tina


1 Answers

You are looking for the result. See here for documentation.

Like so:

$("#Asignacion_Movimiento_OrdenCompra").autocomplete({
 /* your options here*/
}).result(function(event, data, formatted) { // result is a separate function
    alert(data);
});
like image 156
Josiah Ruddell Avatar answered Nov 12 '22 00:11

Josiah Ruddell