Created
May 18, 2021 08:49
-
-
Save yankiara/5551a25983f2a28cf1770993bc27e8f5 to your computer and use it in GitHub Desktop.
Use Oxygen Composite Accordion inside a repeater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//** 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