I am using foundation 5.5.3 and I am trying to setup a simple accordion. I setup everything like in the docs (http://foundation.zurb.com/sites/docs/v/5.5.3/components/accordion.html)
The problem is: I can see that the different categories get the a new class "active" when I click them. They also get aria-expanded="true". However, it does not toggle anything. Moreover, when I click a second time, the class is not removed and aria-expanded stays equal to "true".
Here is my html:
<ul class="accordion" id="myAccordion" data-accordion>
<li class="accordion-navigation"><a href="#cat1">Cat 1</a></li>
<div id="cat1" class="content active">
<ul>
<li><a href="#">Item A</a></li>
<li><a href="#">Item B</a></li>
<li><a href="#">Item C</a></li>
<li><a href="#">Item D</a></li>
</ul>
</div>
<li class="accordion-navigation"><a href="#cat2">Cat 2</a></li>
<div id="cat2" class="content">
<ul>
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
</ul>
</div>
</ul>
Here is my js with console output:
$(document).foundation({
accordion: {
// specify the class used for accordion panels
content_class: 'content',
// specify the class used for active (or open) accordion panels
active_class: 'active',
// allow multiple accordion panels to be active at the same time
multi_expand: true,
// allow accordion panels to be closed by clicking on their headers
// setting to false only closes accordion panels when another is opened
toggleable: true
}
});
$('#myAccordion').on('toggled', function (event, accordion) {
console.log(accordion);
});
Here is my fiddle: https://jsfiddle.net/gfm1ssLa/2/
Any help would be greatly appreaciated... Everything I found on the forum was of no help...
It looks like you just forgot to wrap the content within the list.
<ul class="accordion" id="myAccordion" data-accordion>
<li class="accordion-navigation"><a href="#cat1">Cat 1</a>
<div id="cat1" class="content active">
<ul>
<li><a href="#">Item A</a></li>
<li><a href="#">Item B</a></li>
<li><a href="#">Item C</a></li>
<li><a href="#">Item D</a></li>
</ul>
</div>
</li>
<li class="accordion-navigation"><a href="#cat2">Cat 2</a>
<div id="cat2" class="content">
<ul>
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
</ul>
</div>
</li>
</ul>
The above code should work.