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
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.
David T. 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
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
Ar Chron wrote:
How can I do that?
Perhaps something like this (untested):
%li{:class => ‘myClass’}= blah blah blah
I 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.