flexnav icon indicating copy to clipboard operation
flexnav copied to clipboard

Close all open sub menus when user click another - Feature Request

Open juanfernandes opened this issue 10 years ago • 10 comments

Thank for creating this script - its great.

I've tried to change it do it does this, but my lack of JS knowledge has let me down again.

So basically I need to change it so that when the user clicks another dropdown arrow, all/any already open sub menus, should close.

juanfernandes avatar Jun 16 '14 10:06 juanfernandes

A colleague has fixed this for me - is anyone interested in the code change? Shall I do a pull request?

juanfernandes avatar Jun 16 '14 15:06 juanfernandes

Hi Juan, I would be interested in he code change. For me, this menu scarcely works... Everything stays open and the on over doesn't work either.

vietnamsales avatar Aug 09 '14 20:08 vietnamsales

Hi juanfernandes, Can you please share your code example? Thanks, Michael

Imonda avatar Sep 02 '14 12:09 Imonda

Fix -

$(window).on('resize', myResizer);

function myResizer() {
    $(".flexnav ul").removeClass('flexnav-show').stop(true, true).hide();
}

codehandling avatar Oct 03 '14 11:10 codehandling

That's not a fix for the problem codehandling?!

Can anyone post a real solution for closing all menu's when clicking another? \

behtjes avatar Oct 15 '14 19:10 behtjes

I think he want a Accordion-Behavior which would be very useful. I also would be interested in a solution.

Kinky69 avatar Oct 16 '14 07:10 Kinky69

found it by myself with the code from codehandling:

add $(".flexnav ul").removeClass('flexnav-show').stop(true, true).hide(); to jquery.flexnav.js on line 120 (just under $('.touch-button').on('click', function(e) { )

That will close all tabs first, then open an other!

behtjes avatar Oct 16 '14 08:10 behtjes

Even better solution. It slides up too:

Add $(".flexnav ul").removeClass('flexnav-show').stop(true, true).slideUp(settings.animationSpeed);
after
else if ($sub.hasClass('flexnav-show') === false) {

or just replace the $('.touch-button').on('click', function(e) function with this:

$('.touch-button').on('click', function(e) { var $sub, $touchButton; $sub = $(this).parent('.item-with-ul').find('>ul'); $touchButton = $(this).parent('.item-with-ul').find('>span.touch-button'); if ($nav.hasClass('lg-screen') === true) { $(this).parent('.item-with-ul').siblings().find('ul.flexnav-show').removeClass('flexnav-show').hide(); } if ($sub.hasClass('flexnav-show') === true) { $sub.removeClass('flexnav-show').slideUp(settings.animationSpeed); return $touchButton.removeClass('active'); } else if ($sub.hasClass('flexnav-show') === false) { $(".flexnav ul").removeClass('flexnav-show').stop(true, true).slideUp(settings.animationSpeed); $sub.addClass('flexnav-show').slideDown(settings.animationSpeed); return $touchButton.addClass('active'); } });

behtjes avatar Oct 16 '14 08:10 behtjes

What about if you have some submenus? It shouldn't close the parent if you clik on submenu.

marjanbajc avatar Oct 16 '14 20:10 marjanbajc

didn't took a look at that. the website where I'm using the menu only has 1rst class childs, no submenus.

I'm not very good in jquery, but for submenu's the code needs to be rewritten... Maybe the original developer can help you / us?

behtjes avatar Oct 17 '14 07:10 behtjes