Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't seelct the top level nav item #156

Open
bravo14 opened this issue Dec 26, 2016 · 2 comments
Open

Can't seelct the top level nav item #156

bravo14 opened this issue Dec 26, 2016 · 2 comments

Comments

@bravo14
Copy link

bravo14 commented Dec 26, 2016

I have used the file in a similar way to http://www.balibaytradingcompany.com/ at www.plymouthdevils.co, but can't select the top level nav item

@sashabeep
Copy link

Yep, that's the problem! Also parent level inaccessible on mobile devices

fix

		//dropdown fix, motherfuckers
		function isTouchDevice(){
		if ('ontouchstart' in window || navigator.msMaxTouchPoints) {
					$('html').addClass('touch');
			}
		}
		//run touch test
		isTouchDevice(); //touch detedt
		
		$("html:not(.touch) li.dropdown>a.dropdown-toggle").on("click",function(){
			window.location = $(this).attr("href"); //click parent non-touch
		});
		
		$("html.touch li.dropdown>a.dropdown-toggle").on("click",function(){
			//if already clicked once - go to link(submenu is already opened)
			if($(this).hasClass("oneTouch")){
				$(this).removeClass("oneTouch");
				window.location = $(this).attr("href");
			}

			else{
				$(this).addClass("oneTouch"); //add click counter
				$(".navbar-nav li ul").hide(); //<---- hide all submenus, use your own menu selector
				$(this).parent().find(".dropdown-menu").show();
			}
		});

@scotself
Copy link

scotself commented Jul 18, 2018

I had to add the e.PreventDefault(); before adding the class in the else for this to work for me, but thanks so much!

$("html.touch li.dropdown>a.dropdown-toggle").on("click",function(e){
	//if already clicked once - go to link(submenu is already opened)
	if($(this).hasClass("oneTouch")){
		$(this).removeClass("oneTouch");
		window.location = $(this).attr("href");
	}
	else{
		e.PreventDefault(); // Don't do the default click action without the click counter class.
		$(this).addClass("oneTouch"); //add click counter
		$(".navbar-nav li ul").hide(); //<---- hide all submenus, use your own menu selector
		$(this).parent().find(".dropdown-menu").show();
	}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants