onokumus/metismenu

Clicking a link prevent navigate to the page

dangelion opened this issue · 5 comments

Hi
I need to prevent that clicking on a link, it navigates to the url. I just want it opens the submenu.

I'm using version 3.0.4 with this code:

<ul id="metismenu">
   <li>
     <a href="/about" aria-expanded="false">Menu 1</a>
     <ul>
       <li>Test</li>
       <li>Test</li>
     </ul>
   </li>
   <li>
     <a href="/about" aria-expanded="false">Menu 2</a>
     <ul>
       <li>Test</li>
       <li>Test</li>
     </ul>
   </li>
 </ul>

   $("#metismenu").metisMenu({
     preventDefault: true
   });

For example: if I click "Menu 1" it navigates to the page /about instead I just want it opens the submenu. preventDefault: true seems to not working

Here a Codepen to clearly see this bug: https://codepen.io/anon/pen/LaMgJw

Some help?

What is your project structure?

Hi @onokumus
it's this one: https://github.com/roots/sage

HTML code is inside /resources/views/partials/header.blade.php
JS code is inside /resources/assets/scripts/routes/common.js

Let me know if I answerd

I don't see metisMenu in this repository.

@onokumus That's the third-party boilerplate I'm using, it's not mine. The code is placed where I said before.

I made a codepen https://codepen.io/anon/pen/LaMgJw where you clearly see this bug.
Let me know if helps

Hi @onokumus have you seen the bug in the codepen? Let me know, thanks