Comments (3)
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.
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.
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)
- Bootstrap 5 addon HOT 2
- menu does not render childs at first time HOT 6
- Cannot create property 'guid' on string '.dropdown-menu.show' HOT 6
- menu toggle button not accessible (enough) HOT 4
- smartmenus with "Content-Security-Policy" HOT 6
- Menu Z Index question. HOT 2
- Google SEO 2022: Complete SEO Beginner's Guide
- Pay Per Click vs. Search Engine Optimization
- On-Page vs Off-Page SEO: What's the Difference?
- please add new tag
- A11y: menu toggle button needs a :focus halo HOT 2
- A11y: ESC key should dismiss expanded menu HOT 1
- Second click on link not functional on Bootstrap 5 HOT 1
- A11y: submenus should not open/close on focus HOT 2
- A11y: replace span subIndicator with button HOT 2
- eval of user controlled data? HOT 6
- please add support bootsrap 5 HOT 8
- fix warning
- A11y: add role="button" to span subIndicator HOT 1
- a11y: move the <span> subindicator outside the menu link anchor tag
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smartmenus.