Hello Whey,
You can get the currently selected data item and store it in a global variable in the Kendo UI AutoComplete's select event handler. Then the variable can be used in the button click handler:
The selected item cannot be accessed through the value of the input element, because it is a regular DOM element and its value is a string.
Let me know if you need further assistance.
Regards,
Dimiter Topalov
Telerik
You can get the currently selected data item and store it in a global variable in the Kendo UI AutoComplete's select event handler. Then the variable can be used in the button click handler:
var
currentlySelectedItem;
$(
"#autocomplete"
).kendoAutoComplete({
dataTextField:
"Txt"
,
dataSource: {
data: [
{ Txt :
"GB1"
, value: 1 },
{ Txt :
"GB2"
, value: 2 },
{ Txt :
"GB3"
, value: 3 },
{ Txt :
"GB4"
, value: 4 }
]
},
select:
function
(e) {
currentlySelectedItem =
this
.dataItem(e.item.index());;
}
});
$(
'button'
).click(
function
(){
console.log(currentlySelectedItem);
console.log(kendo.stringify(currentlySelectedItem));
})
The selected item cannot be accessed through the value of the input element, because it is a regular DOM element and its value is a string.
Let me know if you need further assistance.
Regards,
Dimiter Topalov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!