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);
ObtenerDatosAdicionale开发者_如何学Gos();
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.
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);
});
I know this thread is a bit old, but at http://www.phpfreaks.com/forums/index.php?topic=324203.0 I found a working example for select:
select: function(event, ui) {
var selectedObj = ui.item;
alert(selectedObj.value); }
Get the selected option value from the jquery Autocomplete
$("#tags").autocomplete({
source: availableTags,
select: function(event, ui) {
//For better understanding kindly alert the below commented code
alert(ui.toSource());
var selectedObj = ui.item;
alert(selectedObj.value);
}
});
Done!
I added the following to my $(document).ready function:
$('#autocompleteField').result(function (event, data, formatted) {
alert(data);
});
Thank you!
精彩评论