Skip to content

Instantly share code, notes, and snippets.

@yankiara
Created May 18, 2021 08:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yankiara/5551a25983f2a28cf1770993bc27e8f5 to your computer and use it in GitHub Desktop.
Save yankiara/5551a25983f2a28cf1770993bc27e8f5 to your computer and use it in GitHub Desktop.
Use Oxygen Composite Accordion inside a repeater
//** Oxygen Composite Elements Settings Section **//
//** Edit the variables below to change the behavior of the element. **//
var closeOtherToggles = true; // Set this to true to close all other accordions when an accordion is expanded.
//** That's it, stop editing! **/
jQuery(document).ready(function(){
// Expand the content when row is clicked.
jQuery('body').on('click', '.oxel_accordion__row', function() {
jQuery(this).next('.oxel_accordion__content').toggleClass('oxel_accordion__content__hidden');
jQuery(this).children('.oxel_accordion__icon').toggleClass('oxel_accordion__icon__rotated');
if( closeOtherToggles == true ) {
// EDIT FOR REPEATER: Here we use "parent().siblings().children()" because of the repeater structure
jQuery(this).parent().siblings().children('.oxel_accordion__content').not( jQuery(this).next() ).addClass('oxel_accordion__content__hidden');
jQuery(this).parent().siblings().children('.oxel_accordion__row').children('.oxel_accordion__icon__rotated').removeClass('oxel_accordion__icon__rotated');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment