Giter Club home page Giter Club logo

Comments (3)

vadikom avatar vadikom commented on July 20, 2024

Sorry for the late reply! It's been very hectic times here lately. :(

I can see the issue you are facing. To be honest, I am hesitant if it's a good idea to change the behavior for links inside mega dropdown sub menus since in many cases the way it currently works would still be the expected behavior (i.e. hide the sub menu on click even for links in mega dropdowns). So I would suggest you to use a simple additional fix:

// do not hide the mega dropdown sub menu if a link inside it is clicked
$(document).on('click', 'ul.mega-menu a', function(e) {
    e.stopPropagation();
});

It will not hurt your configuration if this behavior is changed in the script core in the future and you decide to upgrade.

from smartmenus.

TylerOrtiz avatar TylerOrtiz commented on July 20, 2024

I tried stopping propagation but it disabled bootstrap's elements relying on clicks too (naturally). I did change the code in the plugin to use an and operator (&&) from an or (||) and this seemed to do the trick nicely. I am aware changing plugins is a bad idea but in the interest of time this seemed to solve everything nicely and I documented the change in our own version of the plugin.

If you're interested, I just changed:

if (this.visibleSubMenus.length && !$.contains(this.$root[0], e.target) || $(e.target).is('a')) {

to:

if (this.visibleSubMenus.length && !$.contains(this.$root[0], e.target) && $(e.target).is('a')) {

I appreciate the help though, thank you vadikom.

from smartmenus.

vadikom avatar vadikom commented on July 20, 2024

I am not sure if you tested with the exact code I posted, but I believe it should work correctly with all Bootstrap JS components. I tested putting an accordion in a mega dropdown:

http://getbootstrap.com/javascript/#collapse-example-accordion

and the clicks work just fine for the accordion and do not hide the sub menu.

The change you've done means that the sub menus will be hidden only when a link on your page that is not contained in your menu tree is clicked.

Anyway, thanks for your input! Cheers!

from smartmenus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.