Forum: Ruby on Rails build a menu (li.selected)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
23fed8aab2d6cc4524346e1e5425a02a?d=identicon&s=25 Paulo Matos (pmatos)
on 2007-07-30 13:20
Hello,

when I try to create a menu I found the following limitation:
the event li.selected does not work
and, I am not being able to show an image when the menu option is
selected

in my CSS exists the following code:
.menu li.selected {
...
background: transparent url(/images/menu_selected.gif) 100% 1px
no-repeat;
...
}

in file: ...\layouts\application.rhtml
exists the following code:
<div id="menu">
<ul>
    <li><%= link_to_unless_current "home", :controller => "home" %></li>
    <li><%= link_to_unless_current "Resources", :controller =>
"resources", :action => "list" %></li>
</ul>

Anyone can tell me how can I do this?
and tell me links source code samples of menus in rails?

thank You very much in advance
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-07-30 13:29
(Received via mailing list)
there is no such thing as an 'event' li.selected.  all you have done
there is define a class 'selected' for an li element  within an
element with the 'menu' class

you will need to add the class attribute to the li element yourself.

per your css/html example:

<div class="menu">
  <ul>
    <li class="selected"> ... </li>
    ...
  </ul>
</div>
23fed8aab2d6cc4524346e1e5425a02a?d=identicon&s=25 Paulo Matos (pmatos)
on 2007-07-30 13:37
Chris Hall wrote:
> there is no such thing as an 'event' li.selected.  all you have done
> there is define a class 'selected' for an li element  within an
> element with the 'menu' class
>
> you will need to add the class attribute to the li element yourself.
>
> per your css/html example:
>
> <div class="menu">
>   <ul>
>     <li class="selected"> ... </li>
>     ...
>   </ul>
> </div>

sorry,

What I'm trying to do is:

when the menu option is "not selected" it has a background image
and
when the menu option is "selected"(chosen by the user) it has another
background image

so, the class can not be fixed by "li"

Can You help me?
thank You very much
This topic is locked and can not be replied to.