Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $99
Get for 99$

Menu with submenu as link


Hey,
I'm trying to create a menu in the header, that menu has submenu, but I also want it to be a link.
the menu item have to be link, and also in the submenu we have to use link.
can look at demo 35:
https://preview.keenthemes.com/metronic8/demo35/

that the menu items in header is not link, only the sub menu items.


Text formatting options
Submit

Replies (6)


Hey Sean,
I'm relating to my co-workers question, Your solution did help but it only works on 'hover' trigger, if I am to add a 'click' trigger too, it's impossible to open the submenu accordion.

currently I added the hover trigger to lg breakpoint, but in mobile you're doomed to use click, which makes it so the accordion won't open, I know why it happens so I'm willing to add the click trigger to the menu-arrow but you're still stuck with "A" tag that wraps but menu-link element.

edit: found a solution, added to your solution is JS:

if (element.hasAttribute("href") && !e.target.classList.contains("menu-arrow")) {
return;
}



Hi,

At the moment this feature is not supported and we will add it in the next update. To enable this you will need to do a small change in src/js/components/menu.js and add a condition element.hasAttribute('href') as shown below:


// Event Handlers
// Toggle handler
var _click = function(element, e) {
if (element.hasAttribute("href") ) {
return;
}

e.preventDefault();

if (the.disabled === true) {
return;
}

var item = _getItemElement(element);

if ( _getOptionFromElementAttribute(item, "trigger") !== "click" ) {
return;
}

if ( _getOptionFromElementAttribute(item, "toggle") === false ) {
_show(item);
} else {
_toggle(item);
}
}


In the HTML just convert span to A for the link:


<a href="#%22%20class=%22menu-link" target="_blank" rel="noopener noreferrer">
...
</a>


Then recompile your assets folder with Gulp or Webpack.

Please note that the build tools are required only in the development environment just to compile the assets when the source folder files are modified. In the hosting/server deployment, you will only need the compile assets, no need to install the build tools dependencies there.

Regards.



Thank you!



Hi,

You are welcome! Please let us know if it worked well. If you need any further help just ping us here.

Regards.



It helped, and worked happy
sorry for delay, didnt see your comment



Great! All the best with your project! happy


Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.
Text formatting options
Submit
Text formatting options
Submit