简体   繁体   English

基础5.0.3刚刚下载,顶栏粘不通

[英]Foundation 5.0.3 just downloaded, top-bar sticky not working

I'm working on upgrading an existing foundation 3 app to the new foundation 5. 我正在努力将现有的基础3应用程序升级到新基础5。

I have the JS loaded fine: <script src="js/foundation/foundation.topbar.js"></script> 我把JS装好了: <script src="js/foundation/foundation.topbar.js"></script>

But I'm seeing this error upon scroll: TypeError: this.settings.sticky_topbar is undefined 但我在滚动时看到此错误: TypeError: this.settings.sticky_topbar is undefined

I've triple checked that I'm using v 5.0.3 straight off the Zurb website, and my markup is very simple: 我已经三次检查我在Zurb网站上直接使用v 5.0.3,我的标记非常简单:

<nav class="top-bar sticky" data-topbar="">
  <!-- Title -->
  <ul class="title-area">
    <li class="name"><h1><a href="#">Sexy Top Bar</a></h1></li>

    <!-- Mobile Menu Toggle -->
    <li class="toggle-topbar menu-icon"><a href="#">Menu</a></li>
  </ul>

  <!-- Top Bar Section -->
  <section class="top-bar-section">

    <!-- Top Bar Left Nav Elements -->
    <ul class="left">

      <!-- Search | has-form wrapper -->
      <li class="has-form">
        <div class="row collapse">
          <div class="large-8 small-9 columns">
            <input placeholder="Find Stuff" type="text">
          </div>
          <div class="large-4 small-3 columns">
            <a href="#" class="alert button expand">Search</a>
          </div>
        </div>
      </li>

    </ul>

  </section>
</nav>

Any ideas would be very much appreciated! 任何想法将非常感谢! I know this sort of behavior was previously reported as a bug in earlier versions, but everything I can find online says 5.0.3 should work fine? 我知道这种行为之前曾被报道为早期版本中的一个错误,但我在网上找到的所有内容都说5.0.3应该可以正常工作吗?

Thanks 谢谢

-James -詹姆士

After reading through foundation.topbar.js, I see that only the topbarContainer having the "sticky" class will cause self.settings.sticky_topbar to be assigned. 阅读了foundation.topbar.js后,我发现只有topbarContainer具有“sticky”类才会导致分配self.settings.sticky_topbar。

So, adding a div.sticky above the nav fixes everything. 因此,在导航上方添加div.sticky会修复所有内容。 Here's my new markup if anyone cares to see it: 如果有人关心的话,这是我的新标记:

<div class="sticky">
  <nav class="top-bar" data-topbar>
    <!-- Title -->
    <ul class="title-area">
      <li class="name"><h1><a href="#">Sexy Top Bar</a></h1></li>

      <!-- Mobile Menu Toggle -->
      <li class="toggle-topbar menu-icon"><a href="#">Menu</a></li>
    </ul>

    <!-- Top Bar Section -->
    <section class="top-bar-section">

      <!-- Top Bar Left Nav Elements -->
      <ul class="left">

        <!-- Search | has-form wrapper -->
        <li class="has-form">
          <div class="row collapse">
            <div class="large-8 small-9 columns">
              <input placeholder="Find Stuff" type="text">
            </div>
            <div class="large-4 small-3 columns">
              <a href="#" class="alert button expand">Search</a>
            </div>
          </div>
        </li>  

      </ul>

    </section>
  </nav>
</div>

Normally Zurb is so awesome at their documentation online. 通常Zurb在他们的在线文档中非常棒。 I wish there was an example for a sticky top bar in there somewhere. 我希望有一个例子,在某处有一个粘顶棒。

Thanks! 谢谢!

-James -詹姆士

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM