CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the attorney
client or other legal privileges, and or proprietary non public
information.
If you are not an intended recipient of this message or an authorized
assistant to an intended recipient, please notify the sender by replying
to
this message and then delete it from your system. Use, dissemination,
distribution, or reproduction of this message and or any of its
attachments
(if any) by unintended recipients is not authorized and may be unlawful.
Give each li an id (i.e. app_nav_li_projects, app_nav_li_files)
Set @li_to_select in your controller or controller method to the li id
you
want to select
Use JQuery on the page to add the selected class to the li id of the @li_to_select
My JQuery looks like this:
Terrible. As I’ve said numerous times on this forum, dynamic JS – and
inline JS even more so – are problematic from a design standpoint and
should always be avoided. What you should be doing here is using an
external JS file to which you pass the ID by a method such as having it
look in the DOM.
But I’m not sure this is the right approach. Rails provides a bunch of
helpers such as current_page? and link_to_if_current_page, so it seems
to me that you should be able to do this on the server side.
Thanks all. I have no intention of wanting to do this client-side with
JS… Only Server Side… Any suggestions? Seems like this is
something every RAils app needs solved?
Thanks all. I have no intention of wanting to do this client-side with
JS… Only Server Side… Any suggestions? Seems like this is
something every RAils app needs solved?
Yes. Read my previous post, where I explained how to do it server-side.