twbs / bootstrap

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
https://getbootstrap.com
MIT License
170.39k stars 78.81k forks source link

Dynamically loaded accordion second level does not expand. #22563

Closed psirimalla closed 7 years ago

psirimalla commented 7 years ago

I have generated 2 levels of dynamic accordions based on data on sharepoint list, when I click on the first level the accordion expands, but when I click on the second accordion it does not expand.

Please suggest what might be wrong: HTML-

JS - $(document).ready(function () { //Level 1 below function close_accordionMain_section() { $('.accordionMain .accordionMain-section-title').removeClass('active'); $('.accordionMain .accordionMain-section-content').slideUp(300).removeClass('open'); } $(document).on('click', '.accordionMain-section-title', function (e) { debugger; // Grab current anchor value var currentAttrValue = $(this).attr('href'); if ($(e.target).is('.active')) { close_accordionMain_section(); } else { close_accordionMain_section(); // Add active class to section title $(this).addClass('active'); // Open up the hidden content panel $('.accordionMain ' + currentAttrValue).slideDown(300).addClass('open'); } e.preventDefault(); }); //Level 2 below function close_accordionSub_section() { $('.accordionSub .accordionSub-section-title').removeClass('active'); $('.accordionSub .accordionSub-section-content').slideUp(300).removeClass('open'); } $(document).on('click', '.accordionSub-section-title', function (e) { debugger; // Grab current anchor value var currentAttrValue = $(this).attr('href'); if ($(e.target).is('.active')) { close_accordionSub_section(); } else { close_accordionSub_section(); // Add active class to section title $(this).addClass('active'); // Open up the hidden content panel $('.accordionSub ' + currentAttrValue).slideDown(300).addClass('open'); } e.preventDefault(); }); }); Please suggest what might be wrong here
Johann-S commented 7 years ago

Sorry, but we cannot help with how-to or general troubleshooting issues here; only bug reports and feature requests. You'll want to ask around in the official Slack team or Stack Overflow. See our readme for more details.