SOLVED: Instead of triggerHandler
in the custom code’s last line, I needed trigger
, because triggerHandler
only targets the first element.
–
My issue is identical to this one in Close dropdown menu
I find the “solution” in Close dropdown menu - #14 by Jd_Bothma as promising but I can’t quite figure out the “right” code to make it work.
This is my code:
<script>
$(".backtomainmenudiv").click(function(){
$(".dropdownlist").removeClass("w--open");
$(".dropdown-toggle").removeClass("w--open");
$(".dropdown-toggle").attr("aria-expanded","false");
$(".navigation").css("z-index", "");
$(".navigation").triggerHandler("w-close.w-dropdown");
});
</script>
It works perfectly on the first item on mobile “Services”, but still has the “two clicks” needed for all other submenus.
PS I wrote my code prior to seeing the “solution” in Close dropdown menu - #14 by Jd_Bothma, and added that last line (triggerHandler) from that solution.
My guess is that something to do with “this.$element.find” is key, but I cannot figure out how to translate my method to that. In other words, I didn’t use “this.$element” elsewhere, and don’t know how to re-write it as such.
Help!
Here is my site Read-Only: LINK
(how to share your site Read-Only link)