0

Please be kind. I am a noob. Just because I didn't post a ton of code on here doesn't mean I haven't done "research". Thing is I'm just looking for direction.

I'm asking for the assistance of a more knowledgeable person of how to use jquery to:

  1. Parse a url
  2. Compare that url with a navigation menu selection
  3. Then if there is a match add a class to that navigation menu item.

Seems simple enough and I've stumbled across several pages, just wondering if I'm heading in the right direction.

Would any of these be the right way to go?

https://github.com/allmarkedup/jQuery-URL-Parser

Parse URL with jquery/ javascript?

Thanks for your help. :)

Community
  • 1
  • 1
  • What do you mean by "compare that url with a navigation menu item?" – Matthew Dean Jan 24 '13 at 22:57
  • Are you trying to set the currently selected menu item or something? And the class you're adding to that navigation menu is like "highlighted" ? – Phu Phan Jan 24 '13 at 23:00
  • For example If a customer was on a page that was http://www.mysite.com/shop/toys to parse the url, then compare that with the site menu and if they are on that toys page then add a class to that so it can be highlighted indicating where the customer is on the website. –  Jan 24 '13 at 23:00
  • Hi Phu Phan, yes thats it. I know there are simpler ways to do this, but I'm using django and I've got the menu being pulled in from my main template and this seems like some hackery, but I'm sure it will work. Just need some direction on it. –  Jan 24 '13 at 23:01
  • 1
    This is something that'd probably be better to do in your server-side code. – Pointy Jan 24 '13 at 23:04

1 Answers1

0

take a look over here it might be just what you're trying to do:

http://gnuvince.wordpress.com/2007/09/14/a-django-template-tag-for-the-current-active-page/

pierdevara
  • 406
  • 2
  • 9