问题
we are using a pre-built admin theme called "Acme Dashboard." When the user clicks on a dropdown child and the child page loads, on the next load the menu item collapses. How can we force the menu to stay open on the next load?
A link to the theme is here: http://wrapbootstrap.com/preview/WB0JLR295
I understand that when the child theme is loaded, the parent is given the class="active" attribute, but I don't know what to change in the CSS/JS to keep the dropdown open.
回答1:
You can use e.stopPropagation()
This will prevent close of any 'dropdown-menu':
$('.dropdown-menu').on('click', function (e) {
e.stopPropagation();
})
If you want only a specific dropdown you'd change the jQuery selector $('.dropdown-menu')
accordingly.
Here is a working example
来源:https://stackoverflow.com/questions/16474551/how-do-i-keep-the-child-menu-open-when-loaded