Setting html id on a sub menu's <ul> with Telerik MVC Menu Control -
using telerik asp.net mvc menu control, i'm trying id on ul's in sub menus. i've tried putting htmlattributes(new { @id="myid" }) call in few places can't seem figure out put id on .
in code snippet below, i've shown 2 places i've tried calling htmlattributes method. comment after call explains telerik control putting id.
@(html.telerik().menu() .name("mainmenu") .items(menu => { menu.add() .text("tools") .items(item => { item.add().text("add toolbox").htmlattributes(new {@id="toolsmenu"}); @* puts id on "add toolbox" <li>*@ item.add().text("toolbox"); }).htmlattributes(new {@id="toolsmenu"}); @* puts id on "tools" <li>*@ menu.add() .text("setup") .items(item => { item.add().text("print header"); item.add().text("menulabelaccountinformation"); }); }).openonclick(true))
is there way id on <ul> control?
you can't set id attribute of ul server side code. use jquery hooking menu's onload client-side event:
<script type="text/javascript"> function onload() { var id = 0; $(this).find("ul").each( function() { this.id = "ul_" + id; id ++; }); } </script>
Comments
Post a Comment