I have tried everything in my knowledge (however little there is), but I can not make the top bar menu render properly on small screens. I want the menu to reduce down to a clickable menu item on small screens, basically responsive behaviour from the menu. Apparently the following code alone should make it work, but it doesn't.
<header>
<div class="row">
<div class="large-12 large-centered small-12 small-centered columns">
<nav class="top-bar" data-topbar role="navigation">
<section class="top-bar-section">
<ul class="title-area">
<li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
</ul>
<ul class="left">
<li><%= link_to('Link', {:controller => 'controller', :action => 'action'}) %></li>
<!-- other links -->
</ul>
<ul class="right">
<li><%= link_to('Link', {:controller => 'controller', :action => 'action'}) %></li>
<!-- other links -->
</ul>
</section>
</nav>
</div>
</div>
</header>
I think it has something to do with javascript related to Foundation but I'm not sure what it is exactly.
EDIT:
application.js :
//
//= require jquery
//= require foundation
//= require jquery_ujs
//= require turbolinks
//= require_tree .
$(document).ready(function() {
$(document).foundation();
});
application.scss
/*
*
*= require_tree .
*= require_self
*= require foundation_and_overrides
*/
@import 'custom';
The custom.scss file imports foundation_and_overrides.scss .
Besides the suggestion below, make sure to change the href in
<ul class="title-area">
<li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
</ul>
to href="" .
I've copied the last comment from http://foundation.zurb.com/forum/posts/2348-foundation-5-topbar-menu-not-responding-on-rails4
You will need to add
gem 'jquery-turbolinks'
to your Gem file then do the usual bundle install
Following this change your javascript manifest file (application.js) to run in the following order:
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require foundation
//= require_tree .
$(function(){ $(document).foundation({});
// any other code etc
//= require turbolinks
This will ensure turbolinks runs AFTER everything else (especially foundation in this case).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.