0

I use jQuery for two DropdownList elements in MVC. But both classes are equally named "chzn-select". When I try to add values there are some conflicts.

Can anybody tell me how to distinguish the "chzn-select" elements?

<tr>
    <td>@Html.Label("branch")
    </td>
    <td>
        @Html.DropDownListFor(m => m.RegionId, (SelectList)ViewBag.Regions, new {@class="chzn-select" ,multiple ="true",data_placeholder = "choose branch", style = "Width:200px", onChange = "regionDropDownChanged();" , tabindex = 3   })
        @Html.ValidationMessageFor(m => m.RegionId)
    </td>
</tr>
<tr>
    <td>@Html.Label("organization")
    </td>
    <td>
        @Html.DropDownListFor(m => m.EnterpriseId, (SelectList)ViewBag.Enterprises, new {@class="chzn-select" ,multiple ="true",data_placeholder = "choose organization", style = "Width:200px", tabindex = 3 })
        @Html.ValidationMessageFor(m => m.EnterpriseId)
    </td>
    <td>
    </td>
</tr>
4

3 回答 3

0

你可以像@class="chzn-select-branch chzn-select" 这样添加一个ID 或添加一个新类。

因此 chzn-select 用于设置 dropdonw 的样式,并使用 chzn-select-branch 使用 jQuery 添加项目

于 2013-06-29T08:09:28.667 回答
0

我同意@alecasciaro。我注意到我主要是添加一个类名来帮助选择器。在处理特定的元素组时会派上用场。

我试图投票给那个答案,但我想我还没有足够的声望点来做任何事情,除了提问或回答。

于 2013-06-29T08:23:52.603 回答
0

您还可以添加自定义属性,如isstyleadded=true,这将允许您做出选择。

于 2013-06-29T08:29:11.627 回答