I have copied across the CSS and HTML structure, but for some reason, the megamenus are not appearing. I don’t think there is any JS involved, so not sure what I am missing.
This is the site that isn’t working:
Can anyone see what I have missed?
Basically the three navigation items on the left should show a mega menu.
finally realised the problem is that this page is using bootstrap5 and the old page used bootstrap4. The dropdown data-toogle attribute changed from this:
Sorry there was so much to look through! How did you work out that was wrong?
I have changed the instances to data-bs-toggle="dropdown" which now doesn’t make the main link go anywhere which is good as it doing that before, but the dropdown/megamenus still don’t seem to appear
It looks like bootstrap expects the megamenu to be the next in sequence but you have a mobile menu in the way which gets shown instead (although you can’t see it).
In the old page you use some custom css using the open class but bootstrap 5 uses the show class instead.
This will show the menu:
.show ~ .dropdown-menu {
display: block;
}
The background colours are missing so you will have to find them again.
It would probably have been better if you duplicated the mobile anchor l,.nk and the mobile menu so that they sit together and then let the desktop and mega menus follow each other as they should. You can hide each in your media query. I need to look into a bit more but the custom css will get the menu showing at least.
I see, that make sense. I have checked the site that it is working on, but can’t see any reference to any JS and also in the files on the working site.
How would I find out what JS it is looking for and I can try to locate it?
Also, I mean as in which tools can I use? I use Inspector/console, but how would I find out what should be firing when it’s not? Are there any other tools I can use?
Debugging js tools are built into chrome but they do need to be learned first.
The problem is exacerbated when you have as many scripts as you have in that site.
I would look at the working site and try to identify the code that makes it work and then see if similar code is not present in the non working version.
When you copy and paste code from one application to another you should ensure they are both running the same framework versions to avoid these issues. You can’t really copy old bootstrap code to a newer version without some alteration.
I’ll try and have another look when I get back to the desktop later tonight.
Still no joy in finding this. I can see the mobile-menu-open is part of a frontend JS script, but is built into the theme, so I wouldn’t have touched that.
Is there an example of this theme that I can look at where the toggle is working?
If all else fails you could write your own click handler for the hamburger to add the appropriate class but that would be a waste if its already baked in to the theme.