为什么我的 Bootstrap 下拉菜单不起作用? [英] Why is my dropdown menu with Bootstrap not working?
问题描述
在我的 Rails 应用程序中,我有以下下拉菜单代码:
<div class="navbar-inner"><div class="容器"><导航><ul class="nav pull-right"><li><%= link_to "Home", root_path %></li><% 如果已登录?%><li id="fat-menu" class="dropdown"><a href="#" class="dropdown-toggle" data toggle="dropdown">帐户 <b class="caret"></b></a><ul class="下拉菜单"><li><%= link_to "Settings", edit_user_path(current_user) %></li><li class="divider"></li><li><%= link_to "退出", signout_path, 方法: "删除" %><%其他%><li><%= link_to "登录", signin_path %><%结束%></nav>
</标题>
在我的 application.js 文件中,我有以下代码:
//= 需要引导程序
我不知道为什么下拉菜单不起作用,也不知道如何修复它.几天前,它运行良好,现在它不再正常运行.感谢您的帮助!
我从之前的 StackOverflow 问题中找到了答案:
我不得不将//= 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屋!