Hi you all, I have a basic menu in my index page which is always shown (Home-New page-List pages, etc.) This menu list is therefore on the layout of the app. However, I would like to change the color (the class from the CSS) of any item when this is the current selected item. The basic way is asking for the "controller.action_name" and make a biiig "if" sentence to manage the possibilities: If controller.action_name="new_page" then <li> Home</li> <li class="selected"> New page</li> <li>List pages</li> Else If... Is there any other short way? 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 -~----------~----~----~----~------~----~------~--~---
Well you can use link_to_unless_current, but you won''t get class="selected". Instead you''ll have to code your CSS based on the existence of a link or not. On May 24, 10:20 am, Damaris Fuentes <rails-mailing-l...@andreas- s.net> wrote:> Hi you all, > > I have a basic menu in my index page which is always shown (Home-New > page-List pages, etc.) > This menu list is therefore on the layout of the app. However, I would > like to change the color (the class from the CSS) of any item when this > is the current selected item. > The basic way is asking for the "controller.action_name" and make a > biiig "if" sentence to manage the possibilities: > If controller.action_name="new_page" then > <li> Home</li> > <li class="selected"> New page</li> > <li>List pages</li> > Else > If... > > Is there any other short way? > Thanks > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
dasil003 wrote:> Well you can use link_to_unless_current, but you won''t get > class="selected". Instead you''ll have to code your CSS based on the > existence of a link or not. > > On May 24, 10:20 am, Damaris Fuentes <rails-mailing-l...@andreas-Thanks! That did work! and just with one or two changes in my CSS :D -- 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 -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes wrote:> dasil003 wrote: >> Well you can use link_to_unless_current, but you won''t get >> class="selected". Instead you''ll have to code your CSS based on the >> existence of a link or not. >> >> On May 24, 10:20 am, Damaris Fuentes <rails-mailing-l...@andreas- > > Thanks! That did work! and just with one or two changes in my CSS :DUm, the thing is that, apart from this menu (I have it at the top, as tabs), in each option I can have a submenu (a set of links at the left). In this case, when I select one of this suboptions, the menu above get unselected... :-S -- 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 -~----------~----~----~----~------~----~------~--~---
Right well, in that case you need to do something more robust anyway because you''ll want the tab to be an active link when you are on any of the subpages. However, you can create a helper that will emulate link_to_unless_current with your own semantics so your template doesn''t get bloated. On May 27, 2:32 pm, Damaris Fuentes <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Damaris Fuentes wrote: > > dasil003 wrote: > >> Well you can use link_to_unless_current, but you won''t get > >> class="selected". Instead you''ll have to code your CSS based on the > >> existence of a link or not. > > >> On May 24, 10:20 am, Damaris Fuentes <rails-mailing-l...@andreas- > > > Thanks! That did work! and just with one or two changes in my CSS :D > > Um, the thing is that, apart from this menu (I have it at the top, as > tabs), in each option I can have a submenu (a set of links at the left). > In this case, when I select one of this suboptions, the menu above get > unselected... :-S > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---