-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown lists : auto close ? #5409
Comments
This component was not built with single page apps in mind. I think it would be good to have. Have you worked out a hook to close the drop-down? |
A solution was posted here: http://foundation.zurb.com/forum/posts/2032-dropdown-button-not-toggling Though I'm sure if this is the best way. |
$(".nav-item").on( "click", function( event ) {
if($('.navbar-toggler').is(':visible')) {
$(".navbar-toggler").trigger('click');
}
}); |
@Danger89's solution worked for me. |
I am working on a website with React and Bootstrap and had the same problem. //get all nav items elements
let navItems = document.querySelectorAll(".nav-link")
//iterate the nav items and add a listener to each of them
navItems.forEach(item => item.addEventListener("click", () => {
//validate if toggler button is displayed
if (document.getElementById("button-toggler").offsetParent !== null) {
//trigger click event of the toggler button
document.getElementById("button-toggler").click()
}
})) |
Just as a side note, mixing frameworks is rarely a good idea (there can be many conflicts). |
Yep, I think the same but, I am not the one who makes desisions. xD |
Hi,
I wonder, for dropdown of the list variety, shouldn't a click/touch on a list element automatically close the dropdown ?
My 2 cents
The text was updated successfully, but these errors were encountered: