Reputation: 69
I have the code below using select
, but this is just giving me the dataItem
, not the event of the select. Is there a way to do this? Or get the event from the dataItem?
var combo = $('#id').data("kendoComboBox");
combo.select(function (dataItem) {
// do something with an event here?
return dataItem.Id === id && dataItem.Name === name;
});
Upvotes: 0
Views: 61
Reputation: 3872
There are two ways to bind to the select event, as can be read here in the documentation:
Subscribing to the event during the initialization:
$("#combobox").kendoComboBox({
dataSource: [ "Apples", "Oranges" ],
select: function(e) {
var item = e.item;
var text = item.text();
// Use the selected item or its text
}
});
Subscribing to the event after the initialization:
function combobox_select(e) {
var item = e.item;
var text = item.text();
// Use the selected item or its text
}
$("#combobox").kendoComboBox({
dataSource: [ "Apples", "Oranges" ]
});
var combobox = $("#combobox").data("kendoComboBox");
combobox.bind("select", combobox_select);
Using combo.select(object)
like in your code calls a method that gets or sets the currently selected item and doesn't register the select event. You can read about it here.
Upvotes: 1