I’m after some clarification on handling parents and children in a mobile menu.
Is it simply just a nested if statement.
Something like (pseudo code below):
If parent has child == true
parent is unclickable
JQuery: toggle show on click
else parent is clickable
That way Home and Contact Us would always be clickable but the others wouldn’t. However would this sort of logic prevent users from clicking the parent in the expanded list?
Thanks and sorry if this has been answered/asked a million and one times.
Can you rephrase the question?
Are you asking if this way of doing it would prevent the users from clicking on “Youth homelessness” in the dropdown menu (grey background color) ?
Isn’t it just easier for users to be able to click on any of the first level menu items instead of having to hover and then select it from the sub-menu?
I’m open to suggestions.
Yeah I think the JS approach is more appropriate.
Thanks for this:
Will this conflict with toggle on click?
I kind of derped on this lol because it’s a nested loop only the first one needs an if statement heh. Thanks
Yes, definitely, but then the same is true on mobile. The question is if you need to repeat it in the submenu, then. I would only do one of those two options. Either have the parent clickable directly but not repeat the menu item in the submenu, or make the parent non- clickable and instead put the link in the submenu. But that’s just my opinion.
You can do your toggling within this event handler. All you do here is to prevent the default behaviour.
Yeah repeating the parent was requested, so I’ll keep it.
If it’s better to have it unclickable and repeated I’ll go with that but what about parents that don’t have children, for example Home and Contact Us? Should they be exceptions?
Thanks
As I said above, that’s my opinion, others may think differently about that. I would make the links without submenus directly clickable. What you could do, is put a little down arrow into those menu items that have submenus, so that it is directly obvious that the link opens a submenu.
I have the same problem, but I don’t understand the solution. I’m sorry for my low level.
Solution CSS.
I understand how working, but that solution isn’t good for me because the text link in menu parent come from “Title” in the document.txt , inside of folders. In other words, I don’t put <a href=" ...> to the link.
Solution javascript.
I think this solution is better, but I don’t know where put this.
I made the submenus in “menu.php” inside the folder “snippets”