So I'm trying to get the dropdown in the navbar from Twitter Bootstrap to work, and I'm having some problems.
Here's my html:
<ul class="nav">
<li class="active"><%= link_to 'Home', root_path %></li>
<li><a href="#">Forums</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">World</a>
<ul class="dropdown-menu">
<li><%= link_to 'Current', current_path %></li>
<li><%= link_to 'All', all_path %></li>
</ul>
</li>
</ul>
And I also have this in the <head>:
<script type="text/javascript" src="http://twitter.github.com/bootstrap/assets/js/bootstrap-dropdown.js"></script>
It's just not working, can anyone see anything wrong with it?
You are referring to a wrong JS file.
Instead of your <script> tag you use, use the following:
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
You can read about it here
At the <ul> class definition, add the relevant nav you wish to use:
<ul class="nav nav-tabs">
-----------------------------^^
or
<ul class="nav nav-pills">
You can also directly link to bootstrap-dropdown.js through as per your comment, but nevertheless you'd need bootstrap css and js included (I also updated the fiddle):
https://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/js/bootstrap-dropdown.js
See fiddle
Also - I see that you use RoR, so make sure it's not a RoR issue on top of the missing JS file.
I have the same issue with bootstrap drop-down(in rails). I resolved the issue by removing the //= require_tree . from application.js. And got worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With