davist11/jQuery-One-Page-Nav

Second click doesn't work

wordica opened this issue · 9 comments

I add this plugin. Works good but if I click on button, it scroll down to section. Then I move page manually to top and trying to click second time on that same button - and nothing. Plugin doesn't work on second click. Every button work only once.

Maybe some more comment. Sometimes it doesn't work at all for second click and sometime it doesn't work only for button "opposite" last clicked button (clicked before this new). When I click some other button - "opposite" start working.

Are you getting any JS errors? Do you have a link?

just a guess

@efectiva you might have other items in your nav which keep user on the same page, that are not being handled by jquery one page nav. You're propably not removing 'active' class of off the tag you specified at navItems: 'a.local-nav' when user clicks on those other anchors, therefore if you click on it again, nothing happens as its already marked as 'active'.

tl;dr The item youre clickin on is already marked as active hence no action.

@davist11 you can preview this problem in the demo:
http://davist11.github.io/jQuery-One-Page-Nav/

if you scroll down manually to the middle of a section and want to return back to this section top by clicking its link you can not

Thanks

That is an intentional decision. You can't click the current item.

@davist11 How Can i change this please ?

You can fork it and modify it to suit your needs.

I'm still a beginner with JavaScript Please help me to do this

I was able to change this with out using a fork.

I wanted blog posts to highlight the current link, but clicking "Blog" to go to the index.

I was adding the current class myelf. Then, after Initializing navbar plugin, create a click event handler on the link you want to change.

$( '#header-nav' ).onePageNav({
	scrollSpeed : 1000,
	changeHash: true,
	filter : ':not(.external)',
	begin : function() {
		$( '#navigation' ).collapse( 'toggle' );
	},
  });

  // Hack for navbar
  $('#blogLink').on('click', function() {
    window.location = '/articles';
  });

Solved the issue.

Thank You