سؤال

This seems so simple, yet I can't figure it out. For some reason, clicking on the dropdown menu is not working, yet everything else in twitter bootstrap is. I'm using ruby on rails. I've already looked at stackoverflow questions that say to simply wrap the whole ul in a div with class "drop down-menu", but that shouldn't be necessary. I should be able to do it inside the ul tag. Any ideas? Thank you.

          <li id="fat-menu" class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            Account <b class="caret"></b>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to "Profile", current_user %></li>
            <li><%=link_to "Settings", '#' %></li>
            <li class="divider"></li>
            <li>
              <%= link_to "Sign out", signout_path, method: "delete" %>
            </li>
          </ul>
        </li>

That is the main code where I believe the problem is. It might be somewhere below (same as above but with less taken out) but i doubt it:

    <ul class="nav pull-right">
      <li><%= link_to "Home", root_path %></li>
      <li><%= link_to "Help", help_path %></li>
      <% if signed_in? %>
        <li><%= link_to "Users", '#' %></li>
        <li id="fat-menu" class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            Account <b class="caret"></b>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to "Profile", current_user %></li>
            <li><%=link_to "Settings", '#' %></li>
            <li class="divider"></li>
            <li>
              <%= link_to "Sign out", signout_path, method: "delete" %>
            </li>
          </ul>
        </li>
        <%= "Technically signed in.  should be true.  It is: " + signed_in?.to_s %>

      <% else %>
        <%= "Technically not signed in.  should be false.  It is: " + signed_in?.to_s %>
        <li><%= link_to "Sign in", signin_path %></li>
      <% end %>
    </ul>

Here is the application.js file

//= require bootstrap
//= require bootstrap-dropdown
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
هل كانت مفيدة؟

المحلول

I finally figured it out. The Javascript was not being called properly. I deleted and recreated the application.js file, and it worked.

نصائح أخرى

I just had the same issue. I disabled turbolinks from application.js.

  1. Remove from application.js:

    //= require turbolinks

  2. Remove turbolinks gem from Gemfile.

  3. Precompiled assets:

    bundle exec rake assets:precompile

  4. Deployed my app to Heroku and everything worked like expected.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top