I'm stumped - I've got two very similar pop up modals - one will close when I click the item from the dynamically generated list, the other will not - the second broken modal instead makes the clicked element disappear and leaves the modal open - the desired behavior would be to append that item to another location (this works) and close the modal.
the x button in the modal with data-close works, I've tried adding data-toggle="modalId"
to the appended elements that make up the selection list in the modal, but to no avail - I even tried inline styling away the modal and overlay with display none but found that it prevented my screen from scrolling.
where the dynamically generated list goes:
<div id="indoor-unit-selection" class="product-selection cell small-11 medium-10 large-6 grid-x reveal" data-reveal aria-labelledby="indoor-unit-selection" aria-hidden="true" >
<a class="close-button" data-close aria-label="Close modal">×</a>
</div>
what triggers the modal appearance:
<div id="indoor-selection5" class="indoor-selection unselected indoor-selection-toggle cell small-10 medium-9 large-6 grid-x grid-padding-x align-center" data-toggle="indoor-unit-selection">
<div class="sub-header2 small-8 medium-10">Select an indoor model</div>
</div>
JS: generates the modal list:
let indoorUnitSelectionGeneration = function () { // to do: need to tie min/max numbers to indoor ductless units
for (let i = 0; i < indoorModelDataArray.length; i++) {
let unit = indoorModelDataArray[i];
if (unit.qtyOnHand) { // only display if its in stock
$("#indoor-unit-selection").append(
'
<div data-toggle="indoor-unit-selection" class="grid-x grid-padding-x align-spaced align-middle text-center">
<div id="${unit.id}" class="indoor-unit-option cell small-11 medium-10 large-6 grid-x grid-padding-x align-spaced text-center">
<div class="indoor-product-description sub-header2 cell small-12">${unit.name}</div>
<img class="cell product-image small-5 medium-6" src="${unit.largeImagePath}">
<div class="product-information-container cell small-7 medium-6 grid-y grid-padding-y align-spaced text-center">
<div class="model-number">Model Number: ${unit.erpNumber}</div>
<div class="qtyOnHand">${unit.qtyOnHand} Available</div>
<a class="more-info" href="https://www.behler-young.com${unit.productDetailUrl}" target="_blank">More Information</a>
</div>
</div>
</div>
<hr id="hr${unit.id}"/>
'
);
};
};
};
indoorUnitSelectionGeneration();
-note: i replaced my template tix for stack overflow formatting
this causes selected item to append to native body element:
$(".indoor-unit-option").click(function(event){
console.warn(event);
showSelectedIndoorUnit(event);
incrimentIndoorUnitCount();
});
let showSelectedIndoorUnit = function (event) {
$(`#indoor-selection${indoorUnitPlaceHolderId}`).append(event.currentTarget);
$(`#indoor-selection${indoorUnitPlaceHolderId}`).addClass('selected').removeClass('indoor-unit-option');
};