Mobile Version Of The Drop Down Menu Doesn't Work Correctly

Solved
Highlighted
New Member
12 0 0
2 0 0

Hello,

My dropdown menu doesn't work correctly on mobile, it's supposed to expand and show the sub categories but instead it redirects to the main collection.

 <i class="fa fa-bars dropdown-toggle icon"></i> is there on the header.liquid but somehow it doesn't work. 

I can also add my mainmenu-mobile.liquid if needed  (Not sure if it's the source of the problem)

Would be great if you could help

Thanks in advance

Ipek

 

 

0 Likes
Highlighted
Shopify Partner
673 109 148

Hello @ipekum, share store link for troubleshooting problem 

0 Likes
New Member
12 0 0

Hello @Wahab_Ahmad ! Here's the link: https://bothstores.com/ 

0 Likes
Highlighted
Astronaut
1142 192 231

Hello,

Thank you for your question. 

Please share your store URL, page URL and also password (if your store has one), I'll help you out to the best of my ability.

Kind regards,
Diego

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes
Highlighted
New Member
12 0 0

Hello, @diego_ezfy !

Here's the store link https://bothstores.com/ 

Unfortunately I can't share the password since I'm an employee to the store, but I can share the codes

 

0 Likes
Highlighted
Astronaut
1142 192 231

@ipekum 

Hey, I developed some code for you.

1. In your Shopify Admin go to online store > themes > actions > edit code
2. In your theme.liquid file, find the </body> (press CTRL + F or command + F on Mac)
3. paste this code right above the </body> tag:

<script>
var a = document.querySelectorAll(`.has-child .site-nav-link`);

if (!a){
	return;
}
for (var each of a){
each.addEventListener('click',function(el){
el.preventDefault();
el.target.classList.toggle('show--dropdown');
});
}
</script>

<style>
@media (max-width:767px){
    .header .nou_megamenu{
    width: 100% !important; 
}
.show--dropdown + .sub-menu-dropdown{
    display: block !important;
}
}
</style>



Let me know whether it works.

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes
Highlighted
New Member
12 0 0

Just updated the code and unfortunately it doesn't seem to be fixing the problem

The toggle icons are now further to the categories and they're still not clickable, redirecting to the main category

By the way, I have some .liquid files including <i class="fa fa-bars dropdown-toggle icon"></i>  which are "mainmenu.mobile", "header.liquid" and mainmenu-mobile.liquid 

Should I try your code on them?

0 Likes
Highlighted
Astronaut
1142 192 231

Send me a screenshot of where you pasted the code plz

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes
Highlighted
New Member
12 0 0

Screen Shot 2020-08-16 at 05.54.27.png

0 Likes
Highlighted
Astronaut
1142 192 231

This is an accepted solution.

There is a typo in my code, sorry, please replace all code with this:


<script>
function mobileFix(){

    var a = document.querySelectorAll(`.has-child .site-nav-link`);

    if (!a){
        return;
    }
    for (var each of a){
    each.addEventListener('click',function(el){
    el.preventDefault();
    el.target.classList.toggle('show--dropdown');
    });
    }
}

mobileFix();
</script>

<style>
@media (max-width:767px){
    .header .nou_megamenu{
    width: 100% !important; 
}
.show--dropdown + .sub-menu-dropdown{
    display: block !important;
}
}
</style>
◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
1 Like