admin管理员组文章数量:1287931
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!
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!
Share Improve this question asked Aug 15, 2016 at 11:01 MCSDMCSD 1512 silver badges12 bronze badges 2- What do you mean - "how do i display the Name and ID of the parent element that made the call " ? Please provide more details on what you whant to achive – Anton Commented Aug 15, 2016 at 13:54
- Your answer below was useful and was the answer i was looking for. It would be interesting to know if there was a way to pass the entire model to the change event..hmm. – MCSD Commented Aug 15, 2016 at 14:57
1 Answer
Reset to default 11You can use this approach to get Id of element on which event have occured
function change(e) {
var elementId = e.sender.element[0].id
}
本文标签: javascriptGet ID attribute from Kendo dropdownList change eventStack Overflow
版权声明:本文标题:javascript - Get ID attribute from Kendo dropdownList change event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741323547a2372344.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论