为了在 Telerik DropDownList 上查询 HtmlAttributes 值,我需要做什么?我知道如何通过 jQuery 做到这一点,但是查询这些的正确方法是什么?
@(Html.Telerik().DropDownListFor(model => model.BookingOfficeIdNew)
.Name("BookingOfficeIdNew")
.HtmlAttributes(new
{
// How do I access these?
@class = "PropertyProposedValueSelect",
@delta = Model.BookingOfficeIdNew,
@container = "BookingOfficeContainer",
@updateFlag = "BookingOfficeIdChanged",
@deltaValue = "BookingOfficeIdOld",
@newValue = "BookingOfficeIdNew",
@newText = "BookingOfficeNameNew"
})
.ClientEvents(events => events
.OnChange("SelectListValueUpdated")
.OnLoad("OnDropDownListLoad")
.OnOpen("OnDropDownListOpen")
)
.BindTo(Model.BookingOfficeIdChanged ? @Html.ToSelectList(Model.BookingOfficeNameNew, Model.BookingOfficeIdNew, true) : ((SelectListItem)ViewData["DefaultSelectListPrompt"]).ToSelectList(true))
.SelectedIndex(0)
.DataBinding(binding => binding.Ajax().Select("RraOfficeSelectListWithPrompt", "Revision"))
)
编辑/回答:我选择使用正确的类名选择父容器;因为 Telerik DropDownList 扩展生成一个 id = "BookingOfficeIdNew" 的输入元素,其父 div 容器具有类 ".t-dropdown"。
$("#BookingOfficeIdNew").parent(".t-dropdown")