I am using the kendo dropdownlisthelper, which has a change event, see below
@(Html.Kendo().DropDownListFor(m => m)
.Name(Model.Name)
.Text(Model.PlaceHolder)
.BindTo(Model.ListItems)
.DataTextField("Text")
.DataValueField("Value")
.Enable(Model.Enabled)
.Events(e =>
{
e.Change("change");
})
.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
Cheers!
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With