bootstrap下拉列表只能工作一半的时间

时间:2015-01-05 11:19:45

标签: javascript css ruby-on-rails-3 twitter-bootstrap-3

如果有效,我点击另一个链接然后停止工作。如果我再次点击相同的链接,它会再次开始工作。我已将CDN排在最前面,将Script放在底部。我不认为它与if语句有任何关系(因为它会隐藏整个导航栏)。

<!-- nav -->
<% if user_signed_in? %>
<nav class="navbar navbar-inverse" role="navigation">
<div class="container-fluid">
  <!-- Brand and toggle get grouped for better mobile display -->
  <div class="navbar-header">
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="bs-example-navbar-collapse-1">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand" href='' > dempow</a>
  </div>

  <!-- Collect the nav links, forms, and other content for toggling -->
 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">

      </li>
    </ul> 
    <ul class="nav navbar-nav navbar-right">
      <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Cont<span class="caret"></span></a>
        <ul class="dropdown-menu" role="menu">
          <li><%= link_to 'Ieşire', destroy_user_session_path %></li>
          <li><%= link_to 'Editare Detalii Cont', edit_user_registration_path %></li>

        </ul>
      </li>
    </ul>
    <% end %> 
  </div><!-- /.navbar-collapse -->

---我刚刚发现崩溃时根本不起作用。

1 个答案:

答案 0 :(得分:0)

您好我在http://getbootstrap.com/components/#nav-dropdowns文档上找到了此下拉示例。尝试删除data-target =“bs-example-navbar-collapse-1”类。 看看http://www.bootply.com/hNlJt7c3hj

的样子
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a></li>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>