Reputation: 1597
I am trying to make an accordion in my website similar to that seen here. However, whenever I click on the place to accordion down, it does not drop but instead links me to my_url#collapseOne (or two or three depending on which one I click on). And, when I load the webpage, menu 1 is already dropped (not desirable) and the other two look correct.
Any ideas on how to properly implement the accordion effect?
Upvotes: 2
Views: 5534
Reputation: 4850
http://twitter.github.com/bootstrap/javascript.html#collapse. If you customized your bootstrap install make sure you have the required files. If you are using the twitter-bootstrap-rails gem with the asset pipeline you should be good to just drop that code in and see it work.
Upvotes: 1
Reputation: 22966
So there are two things you need to do
When the document is ready, you need to initialise your accordions. That means you will go through all of the accordion containers and initialise them to closed.
You will be attaching click event handlers to links that open/close the accordion. To prevent the browser following those link, you should return false from those event handlers, which stops the event from bubbling up any further. This will stop the browser from following the link.
Upvotes: 1