bootstrap-hover-dropdown icon indicating copy to clipboard operation
bootstrap-hover-dropdown copied to clipboard

Can't seelct the top level nav item

Open bravo14 opened this issue 8 years ago • 2 comments

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

bravo14 avatar Dec 26 '16 22:12 bravo14

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();
			}
		});

sashabeep avatar Apr 27 '17 12:04 sashabeep

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();
	}
});

scotself avatar Jul 18 '18 22:07 scotself