Tagged: cornerstone
-
AuthorPosts
-
August 16, 2016 at 5:12 am #1133261
FarBlueIR
ParticipantMorning,
I have read from a previous post from this forum on how to create collapsible sections, which can be expanded/hidden when pressing a button (https://community.theme.co/forums/topic/collapsible-complete-section-accordion-style-javascript-jquery-trouble/), but I was wondering if there was a way to automatically close a section which is already opened, if a new one is opened. At the moment, once you expand a section it will remain open until you click on the same button to close it.
For one of the sections, I have the following examples for the ‘ID’ and ‘Class’ sections:
– ID: one.
– Class: section-expandableThen, under the ‘Custom JS’ settings, I have the following:
jQuery(document).ready(function($){
$(‘#one’).slideToggle(0);
$(‘#one-trigger-button’).click(function(e){
$(‘#one’).slideToggle( “slow” );
e.preventDefault();
});
});Kind regards,
FBIRAugust 16, 2016 at 8:23 am #1133500Paul R
ModeratorHi,
You can try this code.
jQuery(document).ready(function($){ $('#one').slideToggle(0); $('#one-trigger-button').on('touchend click', function(){ $(".section-expandable").not("#one").slideUp(); $('#one').slideToggle( "slow" ); }); });
Hope that helps
August 16, 2016 at 8:49 am #1133530FarBlueIR
ParticipantHi Paul,
Many thanks for your help. I’ve just tried the code from your post and it now works perfectly.
Kind regards,
FBIRAugust 16, 2016 at 11:25 am #1133774Rupok
MemberYou are welcome!
Glad that it helped. Feel free to let us know if you face any other issue. We’ll be happy to assist you.
Thanks for using X.
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1133261 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>