I''ve got a tabbed menu. It currently looks like this in Haml: %ul#menu %li= link_to_unless_current "...", :controller => "..." %li= link_to_unless_current "...", :controller => "..." %li= link_to_unless_current "...", :controller => "..." %li= link_to_unless_current "...", :controller => "..." I would like one of the <li> elements to get an id or class of "current" or "selected" or something when it is the current tab. How can I do that? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Trasbo wrote:> I''ve got a tabbed menu. It currently looks like this in Haml: > > %ul#menu > %li= link_to_unless_current "...", :controller => "..." > %li= link_to_unless_current "...", :controller => "..." > %li= link_to_unless_current "...", :controller => "..." > %li= link_to_unless_current "...", :controller => "..." > > I would like one of the <li> elements to get an id or class of "current" > or "selected" or something when it is the current tab. > > How can I do that? > > Thanks.Perhaps something like this (untested): %li{:class => ''myClass''}= blah blah blah -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ar Chron wrote:>> How can I do that?> Perhaps something like this (untested): > > %li{:class => ''myClass''}= blah blah blahI found a solution based on your suggestion: %li{current("home_page")}= bla bla def current(controller) if @current_controller.eql? controller return {:id => "current"} else return {} end end @current_controller is set in the ApplicationController. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---