SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast Qubito's Avatar
    Join Date
    Sep 2003
    Location
    Mexico
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problems of active state and link_to in RoR

    HI

    I have to problems with a menu. that i am developing in rubyonrails

    first.-
    how could I make that and action (webpage) trigger the active button. and stay active, it normal and hover but doesnot trigger the active state.


    second.-
    how i can set css label inside rubyonrails method link_to
    ex.
    this is that i want. developed with a css application
    <div class="boton"><a href="/empresa/empresa" id="linkempresa"><span>Empresa</span></a></div>

    however when use the method link_to in RoR
    <%= link_to "Empresa" , :action => "empresa" %>
    it appears without <span></span> that i need in order to apply css to that buttons
    <div class="boton"><a href="/empresa/empresa" id="linkempresa">Empresa</a></div>

    help is much appreciated

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can put
    <div class="boton"><&#37;= link_to "<span>Empresa</span>", :action => "empresa" %></div>

    Can you be more specific on the first one?

  3. #3
    SitePoint Enthusiast Qubito's Avatar
    Join Date
    Sep 2003
    Location
    Mexico
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the answer it works.
    well the other issues is

    that i have 3 state botons. normal, hover and active. i want to make the active stay active to tell what page i am, so the active boton remain active in its respective page.

    i would like to know if RoR have a solution for this or it would need to be css

    in case of css I know that i can put body id="thepage"
    and putting rules

    but if I have 2 diferent menus i can not use body id anymore for the second menu
    since it can be only one
    ex. first menu is enterprise, services, marketplace and partners

    then the second menu depends on first
    ex enterprise has a submenu with, news, promotions, contact

    so the thing is that each page should have 2 active botons same time always. one for the principal area and one for the submenu area.

    thanks for any help can be given

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make a css class active and then dynamically assign it to current items.

  5. #5
    SitePoint Enthusiast Qubito's Avatar
    Join Date
    Sep 2003
    Location
    Mexico
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could you post an example ? thanks

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well for css you just put
    .active {
    /*put your code here */
    }
    and then make a template that all controllers will be using and inside of a menu item check request.env[PATH_INFO] variable like:
    <&#37; if request.env[PATH_INFO] == "/the_right_page" %>
    class = "active"
    <% end %>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •