On many webapges we make use of the FAQ modules.
Previously they expanded no problem, suddenly it has broken across every page that makes use of this module and I am not sure how to fix it.
I do not have much knowledge of JavaScript so would need some assistance please in regards to fixing it and where to add it!
This is the current code I have for the FAQ module:
<div class=“accordion”>
<div class=“accordion_group {% if widget.expanded %}expanded{% endif %}”>
<div class=“accordion_header”><span class=“accordion_icon”><i class=“far fa-plus-square”></i></span> {{ widget.faq_question }}</div>
<div class=“accordion_content”>
{{ widget.faq_answer }}
</div>
</div>
</div>
stefen
March 4, 2019, 1:22pm
2
@CandiceLloyd you’re probably missing the javascript. Add this and it should start working:
$('.accordion_header').on('click', function() {
$(this).parent().toggleClass('expanded');
});
If it still doesn’t work, check the console for any other JS errors.
Hey Stefan,
Thank you very much for your input!
This worked well!
Kind regards,
Candice
Ibis
August 29, 2019, 2:10pm
4
I have the same issue.
Where do i paste that code and how?
thanks in advance!
stefen
August 29, 2019, 2:15pm
5
@Ibis you could add it directly below the HTML inside of a script tag.:
<script>
... script goes here ...
</script>
Ibis
August 29, 2019, 2:22pm
6
Hi stefen,
thanks for your fast response. Do you mean like this?
<div class=“accordion”>
<div class=“accordion_group {% if widget.expanded %}expanded{% endif %}”>
<div class=“accordion_header”><span class=“accordion_icon”><i class=“far fa-plus-square”></i></span> {{ widget.faq_question }}</div>
<div class=“accordion_content”>
{{ widget.faq_answer }}
</div>
</div>
</div>
<script> $(‘.accordion_header’).on(‘click’, function() {
$(this).parent().toggleClass(‘expanded’);
}); </script>
Because it did not work. I really do not know a lot about it unfortunately.
best
Giorgio
stefen
August 29, 2019, 2:23pm
7
@Ibis if that didn’t work you might have other javascript errors on the page causing this script not to run because what you posted should work. Do you have a preview link to share?
Ibis
August 29, 2019, 2:46pm
8
stefen
August 29, 2019, 8:31pm
9
@Ibis yes, that first one. It looks like you mixed up the javascript with the HTML. Are you not using the FAQ module?
Ibis
September 9, 2019, 1:46pm
10
hi stefen, apologies for the late respone. I had a flight to catch for vacation!
I did use the FAQ module but it shows as a flat template
stefen
September 10, 2019, 2:37pm
11
You should remove the HTML from the script tag. This HTML should be in the body where you want the tabs to appear on the page..
Hey Giorgio
I am attaching a screenshot of my code where I have gone in to the pages’ template.
On the right side panel to the Additional <head> markup.
You will see the code I used starting beneath: <script type=“text/javascript”>
Hi everyone!
If you’re still struggling with this issue, as we have in the past, we made a simple, feature-rich HubSpot Module for FAQ’s that should work great for any HubSpot CMS page or website if you get fed up with the code.
Check it out here if you’re interested: https://marketplace.hubspot.com/products/begin-bound/beginbound-ultimate-faq-module-live
Happy HubSpotting!