为什么我的 Bootstrap 下拉菜单不起作用? [英] Why is my dropdown menu with Bootstrap not working?

查看:60
本文介绍了为什么我的 Bootstrap 下拉菜单不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Rails 应用程序中,我有以下下拉菜单代码:

</标题>

在我的 application.js 文件中,我有以下代码:

//= 需要引导程序

我不知道为什么下拉菜单不起作用,也不知道如何修复它.几天前,它运行良好,现在它不再正常运行.感谢您的帮助!

解决方案

我从之前的 StackOverflow 问题中找到了答案:

twitter bootstrap 下拉突然不起作用

我不得不将//= require jquery 放在需要引导程序的代码行下方,然后它就起作用了!

In my Rails application, I have the following code for a dropdown menu:

<header class="navbar navbar-fixed-top">
  <div class="navbar-inner">
<div class="container">
    <nav>
            <ul class="nav pull-right">
                <li><%= link_to "Home", root_path %></li> 
            <% if signed_in? %>
                <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 "Settings", edit_user_path(current_user) %></li>
                        <li class="divider"></li>
                        <li>
                            <%= link_to "Sign out", signout_path, method: "delete" %>
                        </li>
                    </ul>
                </li>
            <% else %>
                <li><%= link_to "Sign in", signin_path %>
            <% end %>
            </ul>
        </nav>
  </div>
</div>
</header>

In my application.js file I have the following code:

    //= require bootstrap

I have no idea why the dropdown menu isn't working, and I have no idea how to fix it. A few days ago, it was working fine, and now it no longer functions properly. Thanks for any help!

解决方案

I figured out the answer from this previous StackOverflow question:

twitter bootstrap drop down suddenly not working

I had to put //= require jquery below my line of code that required bootstrap, and then it worked!

这篇关于为什么我的 Bootstrap 下拉菜单不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆