Streaming live at 10am (PST)

Close dropdown menu


#1

I really dont know why this is not built in - its simply a no brainer that you want to close the dropdown when you click the link. Its astonishing.

Anyway, ive tried everything. this is the latest:

('.dropdownmenuitem').on('click', 'a', function() { (’.dropdownmenu’).triggerHandler(‘click’);
});

Doesnt work. Tried the other way to remove the w–open from all div and nav but then I face this annoying issue that I need to click twice on the dropdown to open it again.

Please any help really appreciated. Such a simple thing is turning out to be hell.


Here is my site Read-Only: LINK
(how to share your site Read-Only link)


#2

Hello @mknee :raised_hands:

Maybe you can find an answer here > Ability to close Dropdown Menu after link is clicked

Piter :webflow_heart:


#3

Doesnt help. I am already using

("a").click(function(){ (“nav”).removeClass(“w–open”);
});
("a").click(function(){ (“div”).removeClass(“w–open”);
});

in the form of

('.dropdownmenuitem').each(function(){ (this).click(function(){
("nav").removeClass("w--open"); (“div”).removeClass(“w–open”);
});
});

It closes the dropdown but I need to click twice after to open it again.

Any ideas?


#4

Can you share your read only link?


#5

Its confidential site. I cant share. How can I simulate a click on the body which should close the dropdown. Thats built in right


#6

Update answer (March 2019). Works well on Mobile & Desktop.

custom code --> Copy-paste before body:

<!-- close dropdown with links inside on click -->
<script>
   $(".w-dropdown-list a").click(function(){
      $(".w-dropdown-list").removeClass("w--open");
  });
</script>

image