I'd like some advise on how you handle marking website menus as 'selected' so that you can show different states based on which section of a site you're in. An example is using tabs like the illustration below. When in the first section, the tab has an outline and when moved to the next section, the second tab has the outline +---------+ | Menu #1 | Menu #2 Menu #3 +---------+ Menu #1 | Menu #2 | Menu #3 To clarify, I know how to do the CSS etc. I'm looking for best practice on tracking this state in a Rails app. Once way that I have thought of is to link the menu to the current controller if controller == XYZ menu is selected else menu is normal end This works in simple cases but doesn't work well when using nested resources. Thanks for the help Andrew Timberlake http://ramblingsonrails.com http://MyMvelope.com - The SIMPLE way to manage your savings
on 2009-07-03 06:57
on 2009-07-03 09:51
Andrew Timberlake wrote: > I'd like some advise on how you handle marking website menus as > 'selected' so that you can show different states based on which > section of a site you're in. > An example is using tabs like the illustration below. When in the > first section, the tab has an outline and when moved to the next > section, the second tab has the outline Would current_page be of any help? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org
on 2009-07-03 10:27
On Fri, Jul 3, 2009 at 9:51 AM, Marnen
Laibow-Koser<rails-mailing-list@andreas-s.net> wrote:
>
I don't think so because that seems to do a direct comparison (after
splitting off query params)
I would need something more generic
Andrew Timberlake
http://ramblingsonrails.com
http://MyMvelope.com - The SIMPLE way to manage your savings
on 2009-07-04 00:22
It's probably not ideal, but I've used the simplest possible solution for this in some live code - just set an instance variable in the controller and refer to it in the view / layout where the menu is. You can even set the variable in a before_filter if it is the same across all the actions in your controller. Again, probably not the most "meta" solution available, but able to handle *any* weird site layout you might have. --Matt Jones On Jul 3, 12:56 am, Andrew Timberlake <and...@andrewtimberlake.com>
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.