I have a demo for 3rd Level Navigation that is not being triggerd correctly, not sure where im missing something
DEMO
JS :
$(function(){
$(".dropdown-menu").css("height","auto");
$("#navigation div > .mobile-drop-button").on("click",function(e){
alert('1st level');
e.preventDefault();
if(!$(this).next().next().hasClass("current")){
$(".dropdown-menu").removeClass("current");
$(".dropdown-menu").slideUp();
$(this).next().next().addClass("current");
$(this).find('img').attr('src','/sites/all/themes/enfamil_base/assets/images/up_arrow_white.png');
$(this).parent().siblings().find('img').attr('src','/sites/all/themes/enfamil_base/assets/images/down_arrow_white.png');
$(".current").slideToggle();
}
else{
$(this).next().next().slideUp();
$(this).next().next().removeClass("current");
}
e.stopImmediatePropagation();
});
});
/*****
3rd level SUB NAVIGATION STARTS
******************/
$('a.mobile-drop-button.sub img').on("click", function(e){
alert('3rd level');
$(this).addClass('activeSubNav')
$(".dropdown-menu-sub").show();
e.preventDefault();
})
/*****
SUB NAVIGATION ENDS
******************/
Appreciate your help!
Thanks!!
I have fixed the Issue by using jQuery "slideToggle & sibblings()", as this HTML was so complicated that i dint find correct DOM Flow.
Finally Fixed :-) JS :
$('#navigation .mobile-drop-button-sub').on('click', function(){
var abc = $(this).closest('.menu-option-sub').find('.dropdown-menu-sub').css({'height':'auto'}).height();
//$(this).closest('.menu-option-sub').find('.dropdown-menu-sub').closest('ul.dropdown-menu').css({'height': height + abc})
$(this).closest('.menu-option-sub').find('.dropdown-menu-sub').closest('ul.dropdown-menu').css({'height': height + abc})
$(this).closest('.menu-option-sub').find('ul.dropdown-menu-sub').slideToggle('fast', function(){
$(this).css('height', abc);
$(this).closest('.menu-option-sub').siblings().find('ul.dropdown-menu-sub').css('display','none');
/* $(this).closest('.menu-option-sub').parent('ul.dropdown-menu').css({
'height':'auto'
}); */
$(this).closest('.menu-option-sub').parent('ul.dropdown-menu').css({
'height':'auto'
});
});
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With