Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How much effort would be involved in changing the hover behavior to onclick?
Comments
Comment #1
johnhanley CreditAttribution: johnhanley commentedShame on me for not looking at dynamic_persistent_menu.js prior to asking!
To change the navigation behavior from hover to onclick, simply change the method on line 8 from "mouseover" to "click" like so
Perhaps a nice feature would be to add this as a configurable option.
Comment #2
Sinan Erdem CreditAttribution: Sinan Erdem commentedHi...
Sorry for reopening such an old issue but... I want the sub-menu close if a user clicks on the parent menu item again. I mean a click will toggle the visibility of the sub-menu. Can you think of any solutions to this?
Also I want the sub-menu stay opened. I changed the "Sub-menu timeout" to a very large number. It works, but is it a good solution in terms of performance or something??
Thanks already...
Comment #3
jenlamptonI would also like the ability to choose between a hover-driven or click-driven display change for the sub-menus. This is particularly useful if you are looking for a drop-down menu that will work on tablets, or touch-devices that do not have a hover state.
I ended up also making the same hack as in #1.
In addition, we did not want the child-menu to display automatically for any given section - we wanted the sub-menus to *only* be visible when the parent link was clicked, so we also changed line 120 of the .module file to always, always hide the child menu, as follows:
And then in the .js file I had to change dynamic_persistent_menu_reset function NOT to show the sub-menu.
But, that is a whole other issue. Please see #1211764: Provide different options for how the sub-menus are displayed