x

How to automatically collapse the mobile site navigator once an option is clicked.

Hi All, this is my first post in the Weebly Community and I'm hoping some one will be able to help with a problem I have.

I have just launched a new website (see here http://www.hudsonsteakhouse.co.uk/ ) but I have a problem with the mobile hamburger navigator. 

All links on the navigator takes you to a different section on the home page, apart from Reservations link which takes you to a differernt page. These links work perfectly well from a desktop but when the mobile navigator is used, the navigation "X" doesn't "Auto Collapes" back to a hambuger when an option is clicked/tapped in the navigator.

The navigator needs to Auto Collapes when an option is clicked, then the customer will see the page autoscroll to the relevant section.

My knowlege of HTML / JS is limited but I'm hoping someone can assist me with this issue.

Many thanks in advance.

Chris.

12,193 Views
Message 1 of 11
Report
10 REPLIES 10

Welcome to Community, Eagle22!

First thing I see, you're using a custom theme. Can you revert to a standard theme then test out the site?

12,190 Views
Message 2 of 11
Report

Hi Brodie, 

Thanks for getting back to me.

I've changed the theme to "SRLY - Brisk" but needed to apply a few different colours.

I've tested the Mobile Nav and the problem still occurs. 

When you click on a link (for example "Contact Us") you can see the page scrolls down to the section but the Actual Navigator doesn't dissapear.

However the mobile nav does collapses when you click on the Reservations link as this takes you to a seperate page.

Please advise..

Thank you.

Chris.

12,187 Views
Message 3 of 11
Report
Square

Are you linking in your navigation to anchors on a page, @Eagle22?

12,181 Views
Message 4 of 11
Report

Hi Adam,

I've placed html objects in each section of the page i.e <div id="sectionname"></div>.

Then in the Navigation I've placed http://www.hudsonsteakhouse.co.uk/#sectioname

Hope this helps.

Chris.

12,177 Views
Message 5 of 11
Report
Square

Are they all on the home page of your site? Add "index.html" to all your links like this:

http://www.hudsonsteakhouse.co.uk/index.html#sectioname

12,172 Views
Message 6 of 11
Report

Hi Adam, 

Thanks for your message.

I have tried this appouch before but if I apply this then the smooth scroll down to the section doesn't work.

It simply refreshes the page and jumps direct to the section.

Any other ideas?

Thanks.

Chris.

12,165 Views
Message 7 of 11
Report
Square

I wonder if the smoothscrolling script you're using is interfering in some way.  What happens if you temporarily remove that?

12,161 Views
Message 8 of 11
Report

Hi Adam,

I removed the code from the headerbut the problem still occurs. Without the code the Mobile Nav jumps to the section on the page but the mobile nav still appears on screen.

This is the code I used to create the smooth scroll down to the sections. 

=====

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>

<script>
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>

====

I don't know code well enough but I'm starting to think the code needs modifying so it works in the same manner as this site.. http://www.theovenpizzeria.co.uk/

i.e From the mobile nav, you select an option then the nav collapes back up , then the pages scrolls smoothly to the relevant section.

Hope this helps.

Chris.

12,152 Views
Message 9 of 11
Report
Square

You're probably right, although we can't provide assistance with that kind of custom coding.  Have you thought about trying a different smooth scrolling widget?

12,148 Views
Message 10 of 11
Report

Thanks for letting me know Adam. I have a Designer account - Does Weebly offer such a thing?

3,360 Views
Message 11 of 11
Report