Reputation: 201
I have a Kendo DropDownList with the id SapProject_Id, when user changes its value I need to fire onChange, but this needs to be done in jquery not when I define Kendo DropDownList.
I have tried following code which is not working:
var sapProject = $("#SapProject_Id").data("kendoDropDownList");
sapProject.change = onChange;
function onChange() {
alert(1);
}
Upvotes: 5
Views: 31812
Reputation: 564
For future views of this question, a cleaner way to do this is to use the change
event in the declaration, like so.
$(document).ready(function() {
var dropdown = $("#dropdown-id").kendoDropDownList({
change: dropdownOnChange
}).data("kendoDropDownList");
function dropdownOnChange(e) {
console.log('sap has been changed');
}
});
You can find the telerik documentation for the events here (scroll to the bottom): https://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist
Upvotes: 1
Reputation: 201
The correct way of doing this is:
var sapProject = $("#SapProject_Id").data("kendoDropDownList").bind("change", onChange);
Upvotes: 14