Solved childrens selector bug

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-17 00:59:26 +01:00
parent 954cff051a
commit 0360c443b7
2 changed files with 11 additions and 5 deletions

View File

@ -74,12 +74,11 @@ function openDynamicPopup(subitem) {
alternativesSection.classList.add('d-none');
}
const childrenSection = document.createElement('div');
childrenSection.classList.add('mt-4');
childrenSection.innerHTML = `<h6>Options:</h6><ul class="list-group" id="dynamicChildrenList"></ul>`;
const childrenList = childrenSection.querySelector('#dynamicChildrenList');
const childrenSection = document.getElementById('dynamicChildrenSection');
const childrenList = document.getElementById('dynamicChildrenList');
childrenList.innerHTML = '';
if (subitem.children && subitem.children.length > 0) {
childrenSection.classList.remove('d-none');
subitem.children.forEach(child => {
const listItem = document.createElement('li');
listItem.classList.add('list-group-item', 'd-flex', 'justify-content-between', 'align-items-center');
@ -93,6 +92,8 @@ function openDynamicPopup(subitem) {
childrenList.appendChild(listItem);
});
document.querySelector('.modal-body').appendChild(childrenSection);
} else {
childrenSection.classList.add('d-none');
}
const copyButton = document.getElementById('dynamicCopyButton');

View File

@ -25,6 +25,11 @@
<div id="dynamicModalLink" class="mt-3 d-none">
<a href="#" target="_blank" class="btn btn-primary w-100" id="dynamicModalLinkHref"></a>
</div>
<!-- Options -->
<div id="dynamicChildrenSection" class="mt-4 d-none">
<h6>Options:</h6>
<ul class="list-group" id="dynamicChildrenList"></ul>
</div>
<!-- Alternativen -->
<div id="dynamicAlternativesSection" class="mt-4 d-none">
<h6>Alternatives:</h6>