MCSD MCSD - 1 year ago 226
jQuery Question

Get ID attribute from Kendo dropdownList change event

I am using the kendo dropdownlisthelper, which has a change event, see below

@(Html.Kendo().DropDownListFor(m => m)
.Events(e =>
.HtmlAttributes(new {@id= Model.ID.ToString() })

The function that handles the change event:

function change(e) {
var dataItem = this.dataItem(e.item);
console.log("selected values (" + dataItem.Text + " : " + dataItem.Value + ")");

SO this displays the selected value in the console.

The Question:
I'm struggling to work this out, but how do i display the Name and ID of the parent element that made the call to the change event(in this case the drop-down list).

So basically i want to display these values:
- Name attribute of the dropdown list
- Id attribute of the dropdown list


Answer Source

You can use this approach to get Id of element on which event have occured

function change(e) {
    var elementId = e.sender.element[0].id
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download