This is my first time working with Foundation 6, and I came across this message trying to figure out how to close the new top bar menu on a mobile phone when the link was clicked. I wanted to comment on my decision if someone else working on Foundation 6 runs through this post as it has become a good starting point for me.
Here is what I did:
Navigation installation - horizontal navigation at medium and large control points, responsive to the inclusion of vertical navigation at a small breakpoint
<div class="title-bar" data-responsive-toggle="siteNav" data-hide-for="medium"> <button class="menu-icon" type="button" data-toggle></button> <div class="title-bar-title">Menu</div> </div> <div id="siteNav" class="top-bar"> <p><ul class="vertical medium-horizontal menu text-center"> <li ><a href="#home" onClick="">HOME</a></li> <li ><a href="#services">SERVICES</a></li> <li ><a href="#contact">CONTACT</a></li> </ul></p> </div>
Then I added a modified version of jquery based on previous solutions in this article (thanks to amazingBastard and Cerbrus):
$(document).ready(function($) { $('#siteNav li').click(function() { if(Foundation.MediaQuery.current == 'small'){ $('#siteNav').css('display', 'none'); } }); });
In Foundation 6, the "css" "css" selector is added to the advanced menu, which is either "display: none" for the "hidden" or "display: block" for the advanced menu. This jquery snippet checks the current breakpoint on a small (mobile device) when you click the nav element in the default menu class that I use, and if true changes the css selector to "display: none", effectively closing the menu switch.
source share