Foundation Responsive Top Bar Toggle Not Working In Rails 3.2.8 Project

谁说我不能喝 提交于 2019-12-11 05:09:31

问题


I'm a front-end web developer working on my first serious rails project (v3.2.8). I've successfully installed Foundation version 3.2.0 using the gem.

I am having trouble with the navigation toggle, which appears on smaller screen sizes and is used to expand and collapse the navigation links. When I click on it, it does nothing.

(You can see the documentation for the responsive zurb nav on their website: http://foundation.zurb.com/docs/navigation.php).

The code in question is:

<nav class="top-bar">
   <ul>
      <li class="toggle-topbar">
         <a href="#"></a>
      </li>  
   </ul>  
   <section>
      <ul class="right">
         <li class="has-dropdown">
            <%= link_to "#{@user.email} | #{@user.credits_count}", 
               dashboard_path, :class => 'first-link' %>
            <ul class="dropdown">
               <li>
                  <a href="#">Settings<i class="icon-cog"></i></a>
               </li>
               <li>
                  <a href="#">Downloads<i class="icon-cloud-download"></i></a>
               </li>
               <li>
                  <a href="#">Subscription<i class="icon-calendar"></i></a>
               </li>
               <li>
                  <%= link_to 'Purchase Credits <i class="icon-money"></i>' 
                      .html_safe, credits_path %>
               </li>
               <%= render "shared/menu_bar" %>                 
            </ul>
         </li>
      </ul>
   </section>
</nav>

The odd part is, when I remove:

<ul>
   <li class="toggle-topbar">
      <a href="#"></a>
   </li>  
</ul> 

... Everything works as it should, but the first link:

<%= link_to "#{@user.email} | #{@user.credits_count}", 
             dashboard_path, :class => 'first-link' %> 

... appears twice - Once where the actual toggle arrow should be and again once you click it to expand the navigation links.

Why would the navigation work properly when the toggle is not in the code and malfunction when it is?

Any help would be greatly appreciated.


回答1:


I found this answer on another forum. https://groups.google.com/forum/#!topic/foundation-framework-/-5F_kQWfNQ4

Put the following in the html:

<script src="http://foundation.zurb.com/public/assets/marketing_docs.js"></script>

And at least for me, the dropdown now works...

EDIT: as of Foundation 5 the marketing_docs file is no longer available

I'm currently trying to understand why the toggle isn't working.



来源:https://stackoverflow.com/questions/14392108/foundation-responsive-top-bar-toggle-not-working-in-rails-3-2-8-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!