question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SideNav with dropdown not Closing On Click

See original GitHub issue

Hi, My SideNav only closes when I click direct links, but not within dropdown links. My code:

<div class="navbar-fixed">
    <nav class="teal lighten-2" role="navigation">
        <div class="container">
            <div class="nav-wrapper">
                <div>
                    <ul id="solution1" class="dropdown-content">
                        <li><a href="#" class="">Home</a></li>
                        <li><a href="#card" class="">Benefits</a></li>
                        <li><a href="#platform" class="">Plataform</a></li>
                        <li><a href="#security" class="">Security</a></li>
                        <li><a href="#report" class="">Report</a></li>
                    </ul>
                    <ul id="language1" class="dropdown-content">
                        <li><a href="index_en-us.html" class="">English </a></li>
                        <li><a href="index_pt-br.html" class="">Português </a></li>
                        <li><a href="index_es-es.html" class="">Español </a></li>
                    </ul>
                </div>
                <a id="logo-container" href="#" class="brand-logo"><img src="img/PhishX-Logo-Hor.png" alt="PhishX Logo" height="66" width="150" /></a>
                <a href="" data-activates="nav-mobile" class="button-collapse"><i class="mdi-navigation-menu white-text"></i></a>
                <ul id="nav-desktop" class="right hide-on-med-and-down teal lighten-2 white-text">
                    <b>
                    <li><a class="dropdown-button white-text" href="#!" data-activates="solution1">Solution <i class="mdi-action-dashboard right"></i></a></li>
                    <li><a href="#try" class="white-text">Contact <i class="mdi-action-perm-contact-cal right"></i></a></li>
                    <li><a class="dropdown-button white-text" href="#!" data-activates="language1">Language <i class="mdi-action-language right"></i></a></li>
                    <li><a href="https://portal.phishx.com/" class="white-text" target="_blank">Portal <i class="mdi-action-exit-to-app right"></i></a></li>
                    </b>
                </ul>
                <ul id="nav-mobile" class="right side-nav teal lighten-2 white-text">
                    <b>
                        <li><a class="dropdown-button white-text" href="#!" data-activates="solution1">Solution <i class="mdi-action-dashboard right"></i></a></li>
                        <li><a href="#try" class="white-text">Contact <i class="mdi-action-perm-contact-cal right"></i></a></li>
                        <li><a class="dropdown-button white-text" href="#!" data-activates="language1">Language <i class="mdi-action-language right"></i></a></li>
                        <li><a href="https://portal.phishx.com/" class="white-text" target="_blank">Portal <i class="mdi-action-exit-to-app right"></i></a></li>
                    </b>
                </ul>
            </div>
        </div>
    </nav>
</div>

My init.js:

… $(‘.button-collapse’).sideNav({ closeOnClick: true, ‘edge’: ‘left’ }); $(‘.collapsible’).collapsible(); …

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
daVinci13commented, Mar 2, 2016

Just add on click event to a tag: <a href="#section-contact" onclick="$('.button-collapse').sideNav('hide');">Home</a>

2reactions
atchyutncommented, Jul 28, 2017
$('.button-collapse').sideNav({
		  menuWidth: 300, // Default is 240
		  closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor
		}
	  );
	  $('.collapsible').collapsible();

Use this script.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoid dropdown menu close on click inside - Stack Overflow
First by handling the click on the link to open/close the dropdown like this : ... I just add onclick event like below...
Read more >
How to avoid dropdown menu to close menu items on clicking ...
In this article, We will use stropPropagation method to prevent the dropdown menu from closing the menu list.
Read more >
Off clicking above dropdown does not close ... - GitLab
When opening an item in the group issue board sidebar, off clicking above the context does not close the dropdown. This has to...
Read more >
Navbar dropdown menus not closing at click
I'm looking for an API to close dropdown menu with animation. The problem is probably because you have system animations turned off.
Read more >
How To Create a Side Navigation Dropdown - W3Schools
Click on the dropdown button to open the dropdown menu inside the side navigation. This sidebar is of full height (100%) and always...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found