Kevesebb, mint egy perces olvasmány
Over the last few weeks I've been trying to figure out a way to make navigation's dropdown menus display on click instead of hover.
I added this code to the theme's main.js file.
AUI.add(
'liferay-navigation-interaction-click',
function(A) {
A.mix(
Liferay.NavigationInteraction.prototype,
{
_initChildMenuHandlers: function(navigation) {
var instance = this;
if (navigation) {
navigation.delegate(['click', 'clickoutside'], instance._onMouseToggle, '> li', instance);
navigation.delegate('keydown', instance._handleKeyDown, 'a', instance);
}
},
_onMouseToggle: function(event) {
var instance = this;
var mapHover = instance.MAP_HOVER;
var eventType = 'hideNavigationMenu';
if (event.type == 'click') {
eventType = 'showNavigationMenu';
}
mapHover.menu = event.currentTarget;
Liferay.fire(eventType, mapHover);
},
},
true
);
},
'',
{
requires: ['event-click', 'event-outside', 'liferay-navigation-interaction']
}
);
the click outside event will fire when you click outside of the currently clicked item, which works great for drop downs. Let me know if you have a better way of doing it.
Note: you might need to pull in the newly created module (
liferay-navigation-interaction-click)
in your AUI.ready or AUI.use part of your main.js
Related Assets...
Nincsenek találatok
More Blog Entries...
Daniel Carrillo Broeder
október 21, 2026
Maurice Sepe
október 20, 2026
Yasuyuki Takeo
október 10, 2026
Community
Company
Feedback


