I want to use collapse data-parent options. I need traditional accordion behavior: all collapsible elements under the specified parent should be closed when a collapsible it
It's not working because the data-parent
attribute should be the collapsible (.collapse
) element, instead of the data-toggle
(trigger) element...
https://www.codeply.com/go/akODjGJZjE
<div class="container">
<div class="content-nav">
<a role="button" data-toggle="collapse" aria-expanded="false" aria-controls="content-nav__book_third" href="#content-nav__book_third" class="content-nav__book content-nav__book_third">3</a>
<a role="button" data-toggle="collapse" aria-expanded="false" aria-controls="content-nav__book_second" href="#content-nav__book_second" class="content-nav__book content-nav__book_second">2</a>
<a role="button" data-toggle="collapse" aria-expanded="true" aria-controls="content-nav__book_first" href="#content-nav__book_first" class="content-nav__book content-nav__book_first">1</a>
</div>
<!--.content-nav-->
<div id="content-articles">
<div id="content-nav__book_third" data-parent="#content-articles" class="content-article collapse">
<div id="content-article__info_third-1" data-parent="#content-nav__book_third" class="content-article__info collapse">
Book 3 article 1
</div>
<!--.content-article__info-->
<div id="content-article__info_third-2" data-parent="#content-nav__book_third" class="content-article__info collapse">
Book 3 article 2
</div>
<!--.content-article__info-->
<div id="content-article__info_third-3" data-parent="#content-nav__book_third" class="content-article__info collapse">
Book 3 article 3
</div>
<!--.content-article__info-->
<div class="content-article__plan">
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_third-1" href="#content-article__info_third-1" class="content-article__plan-link content-article__plan-link_third-1">Link - Book 3 article 1</a>
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_third-2" href="#content-article__info_third-2" class="content-article__plan-link content-article__plan-link_third-2">Link - Book 3 article 2</a>
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_third-3" href="#content-article__info_third-3" class="content-article__plan-link content-article__plan-link_third-3">Link - Book 3 article 3</a>
</div>
<!--.content-article__plan-->
</div>
<!--.content-article-->
<div id="content-nav__book_second" data-parent="#content-articles" class="content-article collapse">
<div id="content-article__info_second-1" data-parent="#content-nav__book_second" class="content-article__info collapse">
Book 2 article 1
</div>
<!--.content-article__info-->
<div id="content-article__info_second-2" data-parent="#content-nav__book_second" class="content-article__info collapse">
Book 2 article 2
</div>
<!--.content-article__info-->
<div id="content-article__info_second-3" data-parent="#content-nav__book_second" class="content-article__info collapse">
Book 2 article 3
</div>
<!--.content-article__info-->
<div class="content-article__plan">
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_second-1" href="#content-article__info_second-1" class="content-article__plan-link content-article__plan-link_second-1">Link - Book 2 article 1</a>
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_second-2" href="#content-article__info_second-2" class="content-article__plan-link content-article__plan-link_second-2">Link - Book 2 article 2</a>
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_second-3" href="#content-article__info_second-3" class="content-article__plan-link content-article__plan-link_second-3">Link - Book 2 article 3</a>
</div>
<!--.content-article__plan-->
</div>
<!--.content-article-->
<div id="content-nav__book_first" data-parent="#content-articles" class="content-article collapse show">
<div id="content-article__info_first-1" data-parent="#content-nav__book_first" class="content-article__info collapse">
Book 1 article 1
</div>
<!--.content-article__info-->
<div id="content-article__info_first-2" data-parent="#content-nav__book_first" class="content-article__info collapse">
Book 1 article 2
</div>
<!--.content-article__info-->
<div id="content-article__info_first-3" data-parent="#content-nav__book_first" class="content-article__info collapse">
Book 1 article 3
</div>
<!--.content-article__info-->
<div class="content-article__plan">
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_first-1" href="#content-article__info_first-1" class="content-article__plan-link content-article__plan-link_first-1">Link - Book 1 article 1</a>
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_first-2" href="#content-article__info_first-2" class="content-article__plan-link content-article__plan-link_first-2">Link - Book 1 article 2</a>
<a data-toggle="collapse" aria-expanded="false" aria-controls="content-article__info_first-3" href="#content-article__info_first-3" class="content-article__plan-link content-article__plan-link_first-3">Link - Book 1 article 3</a>
</div>
<!--.content-article__plan-->
</div>
<!--.content-article-->
</div>
<!--#content-articles-->
</div>