ChrisWojcik / single-page-nav

jQuery plugin that provides smooth scrolling and advanced navigation for single page websites.
http://chriswojcik.net/demos/single-page-nav/
161 stars 74 forks source link

Using full url with # stops adding the current class . #4

Closed pankajk1018 closed 10 years ago

pankajk1018 commented 10 years ago

Hello Chris When i change the url for example "#section1" to "http://localhost/project/#section1" it stops adding current class to that menu item when clicked or scrolled to that related section. Will you please provide any solution for this. Thank you.

ChrisWojcik commented 10 years ago

Can you provide a link to a test page showing this issue. I'm not sure I understand exactly what you mean.

camslice commented 10 years ago

I too am having this problem. In this example, the 'current' class is correctly applied to the navigation items as you scroll down the page. The href attributes start with a hash: http://hastebin.com/yawosonuwu.xml

If you prefix the hash in the href attributes - eg: "demo.html#section1" - the 'current' class is no longer applied to the navigation items: http://hastebin.com/kojewucopo.xml

techgyver commented 10 years ago

just add a $ after the href-attribute selector to match the end of the string and not the whole link line 136:

var $activeLink = this.$container.find("a[href$='" + href + "']");
camslice commented 10 years ago

Thanks! Love wildcards in attribute selectors. I'm actually using one for the 'filter' property. Didn't occur to me that the plugin would use them.

Are you going to commit this change to the next release?

On Mon, Mar 31, 2014 at 1:27 AM, techgyver notifications@github.com wrote:

just add a $ before the attribute selector in line 136: <<< var $activeLink = this.$container.find("a[href='" + href + "']");

var $activeLink = this.$container.find("a[href$='" + href + "']");

-- Reply to this email directly or view it on GitHubhttps://github.com/ChrisWojcik/single-page-nav/issues/4#issuecomment-39026684 .

ChrisWojcik commented 10 years ago

Thanks for the great fix. I've committed the change.

pankajk1018 commented 10 years ago

Thanks that was a great fix..

camslice commented 10 years ago

nailed it :)

On Wed, Apr 23, 2014 at 2:54 PM, pankajk1018 notifications@github.comwrote:

Thanks that was a great fix..

— Reply to this email directly or view it on GitHubhttps://github.com/ChrisWojcik/single-page-nav/issues/4#issuecomment-41124671 .