Skip to content

Commit

Permalink
Updated the block to buildAutoBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
teshukatepalli1 committed Dec 8, 2023
1 parent 63d6649 commit b80982c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions blocks/order-form/order-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function decorate(block) {
export default function buildAutoBlocks(block) {
const para = block.innerText;
block.innerHTML = para;
const forms = block.querySelectorAll('form');
Expand All @@ -9,10 +9,12 @@ export default function decorate(block) {
form.action = originalUrl.replace(/(\?|&)continue=([^&]*)/, `$1continue=${continueUrl}`);
});
const accordions = block.querySelectorAll('.mmg-collapsible');
accordions.forEach((accordion) => {
accordion.children[0].addEventListener('click', () => {
const content = accordion.querySelector('.content');
content.style.display = content.style.display === 'none' ? 'block' : 'none';
if (accordions.length > 0) {
accordions.forEach((accordion) => {
accordion.children[0].addEventListener('click', () => {
const content = accordion.querySelector('.content');
content.style.display = content.style.display === 'none' ? 'block' : 'none';
});
});
});
}
}

0 comments on commit b80982c

Please sign in to comment.