8

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!!

3
  • How it's not working correctly? What is the issue?
    – ketan
    Dec 15, 2015 at 4:45
  • I think it's because of your display: none !important; of .dropdown-menu-sub so jQuery gives it display: block; but still doesn't effective.
    – Tsumannai
    Dec 15, 2015 at 4:57
  • @ketan : if you click on 3rd level ul is not being displayed
    – Developer
    Dec 15, 2015 at 4:58

1 Answer 1

1

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

        });
    })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.