I'm a beginner with javascript and jquery, I am using opencart and a filter extension.
I am trying to get only one data-toggle to show at a time.
The filter extension has multiple options like category, size, category, colour, etc. Each option when clicked shows a hidden div when when clicked again hides it.
Each option can be clicked and all hidden divs can be shown at the same time. I am trying to make only one option show at a time, so for example option A is clicked it opens but if option B is clicked while A is open - B opens and A closes. Kind of like a toggle.
I believe the javascript doing this is in the bootstap.js include. But each option clicked does this to it's html:
When a option is clicked (Open):
<div class="af-container">
<div class="af-heading af-collapse collapsed" data-toggle="collapse" aria-expanded="false" data-target="#s">
<p>Category:</p><span></span>
</div>
<div aria-expanded="false" id="s" class="af-elements collapse" style="height: 0px;">
</div>
</div>
When open collapsed class is added and aria-expanded is set to "false", in the div below aria-expanded is set to "false" also.
When an open option is click (Closed):
<div class="af-container">
<div class="af-heading af-collapse" data-toggle="collapse" aria-expanded="true" data-target="#s">
<p>Category:</p><span></span>
</div>
<div aria-expanded="true" id="s" class="af-elements collapse in" style="">
</div>
</div>
When closed collapsed class is removed and aria-expanded is set to "true" and in the following div aria-expanded is set to "true" and in class is added to div, also height is removed from style.
The "html" code seems to be within a .tag file:
<af_group>
<div class="af-container">
<div class="af-heading af-collapse" data-toggle="collapse" data-target="#{filter.name}_{filter.group_id}_{opts.filter_id}" aria-expanded="true">
<p class="title">{filter.caption}</p><span></span>
</div>
<div id="{filter.name}_{filter.group_id}_{opts.filter_id}" class="af-elements collapse {filter.collapse == '0'?'in':''}" aria-expanded="true">
<div class="af-wrapper">
<div data-is='af_group_{filter.type}' filter={filter} filter_id={opts.filter_id}></div>
</div>
</div>
</div>
</af_group>
What is the best way to only have one open at a time? Is there a simple solution or would maybe javascript that overrides / adds to the bootstrap.js (if it is that) to allow only one collapsed class to be allowed at a time for example?
Any help would be appreciated!
collapse? - Gerardo BLANCO