I have a simple navigation menu that has simple HTML links which target different pages. All these pages share this menu, which are partially separated.
I have to highlight the current page's link in bold. A generic version of my (non-functional) implementation looks like this:
# 'Pagetu' view & lt;% @bold = "pagetwo"%> & Lt;% = Render: Partial = & gt; "Share / Navigation"% & gt; # Partial & lt;% = link_to "home", home_url ,: id = & gt; "Home"%> & Lt;% = link_to "Page 1", pageone_url ,: id = & gt; "PageOn"%> & Lt;% = link_to "Page 2", pagetwo_url ,: id = & gt; "Pageto"%> & Lt;% if @ bold. Present? & Gt%; & Lt; Script & gt; Document.getElementById ('& lt;% = @ bold% & gt;'). Bold (); & Lt; / Script & gt; & Lt;% end% & gt; If this is a terrible implementation, then I would appreciate any help in improving it - it can improve my understanding of how to accomplish these things in the future. Of course, the small problem is that the above code does not work properly! Note - The script tag appears with the correct value - it's not really actually making the text bold. Note 2 - I would not like to use JQuery / Prototype for solution if possible.
link_to_unless_current The suggestion is working Do anyone know how to separate each CSS class to use this method?
The courage of the relationship between page requests (i.e. in response to client side events) For example, consider using block types,
Another option may be to add a class to the body based on your current page (or the same container element) and then link the links in specific contexts To write the CSS rules. For example:
body.home a # home_link {font-weight: bold} body.about # about_link {font-weight: bold}
Comments
Post a Comment