Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap - dropdown menu not working?

My dropdown menu in Bootstrap doesnt appear to be working - can anyone alert me to the problem? Right now it displays the dropdown, but clicking it does nothing. Thanks!

JS:

$(document).ready( function() { $('.dropdown-toggle').dropdown(); }); 

HTML:

<div class="navbar navbar-fixed-top">     <div class="navbar-inner">         <div class="container" style="width: auto;">              <a class="brand" style="text-indent: 3em" href="#">                 Title             </a>              <ul class="nav">                 <li><a href="#">Profile</a></li>                 <li class="active"><a href="#">Statistics</a></li>                 <li><a href="#">Reader</a></li>                  <li class="dropdown" id="menu1">                     <a class="dropdown-toggle" data-toggle="dropdown" href="#menu1">                     Options                     <b class="caret"></b>                     </a>                     <ul class="dropdown-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>     </div> </div> 
like image 428
theeggman85 Avatar asked Mar 02 '12 07:03

theeggman85


People also ask

How do I open a dropdown in bootstrap?

To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. The . caret class creates a caret arrow icon (), which indicates that the button is a dropdown.

What is drop down menu in bootstrap?

Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown JavaScript plugin. They're toggled by clicking, not by hovering; this is an intentional design decision.


2 Answers

Check if you're referencing jquery.js BEFORE bootstrap.js and bootstrap.js is loaded only once. That fixed the same error for me:

<script type="text/javascript" src="js/jquery-1.8.0.js"></script> <script type="text/javascript" src="js/bootstrap.min.js"></script> 
like image 125
djGrill Avatar answered Oct 15 '22 13:10

djGrill


This is a Rails specific answer, but I had this same problem with Bootstrap dropdown menus in my Rails app. What fixed it was adding this to app/assets/javascripts/application.js:

//= require bootstrap

Hope that helps someone.

like image 33
jimbonk Avatar answered Oct 15 '22 13:10

jimbonk