Replies: 1 comment 1 reply
-
|
You could set up an event listener on up.on('up:link:follow', function() {
const toggler = document.querySelector('#nav');
if (toggler) { // You'll also need to check that the navigation is open before closing it
toggler.click();
}
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My website shows a toggler (Menu burger icon) for nav bar on mobile devices. When a uses clicks on any item from toggler's menu, I want the dropdown to close automatically.
Normally, I would just get the togger element and send a click to it, like this:
However, my website uses jQuery which dynamically inserts the toggler element when page load completes. So, toggler is always null because jQuery inserts the toggler element as the last thing.
Does Unpoly provide any utility function to help me run my above code after jQuery? Or, any other way to auto close the toggler dropdown on mobile devices?
Beta Was this translation helpful? Give feedback.
All reactions