简体   繁体   English

下载菜单未显示在iPhone Bootstrap 4 Alpha上

[英]Dropdown Menus not Showing on iPhone Bootstrap 4 Alpha

I am having trouble working with the 4.0.0-alpha.6 release of Bootstrap 4 on iPhone (but not Android). 我在iPhone(但不是Android)上使用Bootstrap 4的4.0.0-alpha.6版本时遇到问题。 Our nav bar has two dropdown menus that work fine on desktop (and in developer tools for testing responsive activity). 我们的导航栏有两个下拉菜单,可以在桌面上正常工作(以及用于测试响应活动的开发人员工具)。 But when viewed on an iPhone the dropdowns do not work. 但是当在iPhone上查看时,下拉菜单不起作用。 It looks as though the there is an issue with the javascript - clicking on the dropdown should be adding the “show” class, but it does not do so on iPhone. 看起来javascript存在问题 - 点击下拉列表应该添加“show”类,但它不会在iPhone上执行。 Manually adding the “show” class by manipulating the DOM with developer tools brings about the expected CSS change and shows the dropdowns correctly. 通过使用开发人员工具操作DOM来手动添加“show”类会带来预期的CSS更改并正确显示下拉列表。 Can anyone advise on what might be keeping the javascript from working here? 任何人都可以建议什么可能保持javascript在这里工作? We're not getting any errors in the console. 我们在控制台中没有收到任何错误。

Our repository is here . 我们的存储库在这里 We're running Jekyll and Ruby 2.3.3. 我们正在运行Jekyll和Ruby 2.3.3。

The particular HTML snippet in question that is not getting JavaScript fired on it is the /_includes/menu.html from the repo: 没有获得JavaScript的特定HTML代码段是来自repo的/_includes/menu.html:

<nav class="navbar navbar-toggleable-sm navbar-light bg-faded">
  <!--<div class="container">-->
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="{{site.baseurl}}{{site.data.snippets.menu-home[page.lang]}}">The Programming Historian</a>
  <div class="collapse navbar-collapse" id="navbarNavDropdown">
    <ul class="nav navbar-nav ml-auto w-100 justify-content-end">
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            {{site.data.snippets.menu-about[page.lang]}}
          </a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
            <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-about-overview[page.lang].link}}">{{site.data.snippets.menu-about-overview[page.lang].title}}</a>
            <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-about-team[page.lang].link}}">{{site.data.snippets.menu-about-team[page.lang].title}}</a>
            <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-about-research[page.lang].link}}">{{site.data.snippets.menu-about-research[page.lang].title}}</a>
          </div>
        </li>

      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          {{site.data.snippets.menu-contribute[page.lang]}}
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink2">
          <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-contribute-overview[page.lang].link}}">{{site.data.snippets.menu-contribute-overview[page.lang].title}}</a>
          <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-contribute-feedback[page.lang].link}}">{{site.data.snippets.menu-contribute-feedback[page.lang].title}}</a>
          <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-contribute-review[page.lang].link}}">{{site.data.snippets.menu-contribute-review[page.lang].title}}</a>
          <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-contribute-write[page.lang].link}}">{{site.data.snippets.menu-contribute-write[page.lang].title}}</a>
          <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-contribute-edit[page.lang].link}}">{{site.data.snippets.menu-contribute-edit[page.lang].title}}</a>
          <a class="dropdown-item" href="{{site.baseurl}}{{site.data.snippets.menu-contribute-retirement[page.lang].link}}">{{site.data.snippets.menu-contribute-retirement[page.lang].title}}</a>
        </div>
      </li>

      <li class="nav-item">
        <a class="nav-link" href="{{site.baseurl}}{{site.data.snippets.menu-lessons[page.lang].link}}">{{site.data.snippets.menu-lessons[page.lang].title}}</a>
      </li>

      <li class="nav-item">
        <a class="nav-link" href="{{site.baseurl}}{{site.data.snippets.menu-blog[page.lang].link}}">{{site.data.snippets.menu-blog[page.lang].title}}</a>
      </li>

      <li class="nav-item">
        <a class="nav-link lang" href="{{site.baseurl}}{{site.data.snippets.menu-lang[page.lang].link}}">{{site.data.snippets.menu-lang[page.lang].title}}</a>
      </li>


    </ul>
  </div>
  <!--</div>-->
</nav>

Our header file containing all of the javascript references is at /_includes/header.html: 我们包含所有javascript引用的头文件位于/_includes/header.html:

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    {% include metadata.html %}

    {% include twitter-card.html %}

    <!-- Mobile viewport optimized: h5bp.com/viewport -->
    <meta name="viewport" content="width=device-width">

    <link href="{{site.baseurl}}/css/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">

    <link href='{{site.baseurl}}/feed.xml' rel='alternate' type='application/atom+xml'>

    <title>{{ page.title }} | {{ site.name }}</title>

    <link href="https://fonts.googleapis.com/css?family=Crete+Round|Open+Sans|Quattrocento|Roboto|Roboto+Condensed" rel="stylesheet">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
    <link rel="stylesheet" href="{{site.baseurl}}/css/github.css">
    <link rel="stylesheet" href="{{site.baseurl}}/css/style.css">

    <script
      src="https://code.jquery.com/jquery-3.2.1.min.js"
      integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
      crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

    <script type="text/javascript" src="{{site.baseurl}}/js/ext_links.js"></script>
    <script type="text/javascript" src="{{site.baseurl}}/js/header_links.js"></script>
    <script type="text/javascript" async
      src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
    </script>

  </head>

We're running the 4.0.0-alpha.6 release of Bootstrap JS and CSS. 我们正在运行Bootstrap JS和CSS的4.0.0-alpha.6版本。 I've explored the responses here and here , but those workarounds didn't seem to work. 我已经在这里这里探讨了这些反应,但这些变通办法似乎没有用。 Googling suggested that this was a known issue for BS4-alpha at the time, so I tried upgrading our version of Bootstrap to the latest stable release as per the documentation on BS4 available here . 谷歌搜索建议这是当时BS4-alpha的一个已知问题,所以我尝试将我们的Bootstrap版本升级到最新的稳定版本,根据此处提供的BS4文档。 That does not fix the issue, though, and it also introduces other style issues that would be expected from such a migration. 但是,这并不能解决问题,而且还会引入这种迁移所期望的其他样式问题。 So I've left off from migrating right now. 所以我现在已经不再迁移了。 Any guidance on what might be getting lost in such a migration would be helpful, if that's the best solution. 如果这是最佳解决方案,那么在此类迁移中可能会丢失的任何指导都会有所帮助。

Any help would be very appreciated, and I'm happy to give any further context or code required. 任何帮助将非常感激,我很乐意提供任何进一步的上下文或代码。

In case it helps anyone else in the future, I got this to work by adapting the code here . 如果将来它帮助其他任何人,我通过调整代码来实现这一点 That link provides a little javascript to cover the functionality, though I had to adapt the jQuery selectors to make the code fit the structure of the html as we had it set up. 该链接提供了一些javascript来覆盖功能,但我必须调整jQuery选择器以使代码适合我们设置的html结构。

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

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