I see. Note, the issue is not with the "first level" LI elements only -- 
none of the LI elements get a class unless they include a sub-menu to be 
expanded (in which case, the default class is "web2py-menu-expand"). 
However, if you just need a CSS selector to get at particular LI elements, 
you should be able to do it using child element selectors. For example:

ul.sf-menu > li

is the selector for all first-level LI elements in the menu. And if you use 
the default "web2py-menu-vertical" for the sub-menu UL's, then:

ul.web2py-menu-vertical > li

would be the selector for all LI elements within sub-menus.

Anthony

On Wednesday, February 15, 2012 9:29:47 AM UTC-5, shartha wrote:
>
> Thanks Anthony for your reply. But actually this didn't help me. Your 
> code still would set the class for the outer UL element and generate 
> the following html. As you can see the <li> tag -- line 3 -- is still 
> without a class name. It seems that there is no way to set a class 
> name for this tag using web2py. Am I right? Thanks you again! =) 
>
> 1. <div id="menu"> 
> 2.    <ul class="your-custom-class"> 
> 3.       <li> 
> 4.          <a href="/myApp/default/index">Home</a> 
> 5.       </li> 
> 6.    </ul> 
> 7. </div> 
>
>
> On Feb 14, 8:52 pm, Anthony <[email protected]> wrote: 
> > > the default MENU helper sets the class for the outer UL elements to 
> > > "sf-menu". There are optional arguments to set the class of the inner 
> > > UL and LI elements. What I need is a way to set the class for the 
> > > first level (outer) LI element. Is there any way to do this other than 
> > > using JavaScript/jQuery, i.e. with arguemtns? 
> > 
> > Actually, the default class for the outer UL is "web2py-menu 
> > web2py-menu-vertical". It is explicitly set to "sf-menu" in layout.html 
> of 
> > the "welcome" app (so it works properly with Superfish): 
> > 
> > <div id="menu"> 
> >     {{=MENU(response.menu, _class='mobile-menu' if is_mobile else 
> > 'sf-menu', mobile=is_mobile)}} 
> > </div> 
> > 
> > As you can see, all you have to do is set the _class argument: 
> > 
> > {{=MENU(response.menu, _class='your-custom-class')}} 
> > 
> > Anthony

Reply via email to