On our ColdFusion page, we have a dynamic list of paired divs created using a loop over a query. For example, each pair consists of internshipHandleX and internshipHiddenX:
<div id="internshipHidden#internship.currentrow#" class="hidden pop-up">
We aim to connect these divs as modal windows along with their corresponding triggers. The following code snippet demonstrates our attempt:
for (var row = 1; row <= totalInternships; row ++){
var thisHandle = "#internshipHandle" + row;
var thisHidden = "#internshipHidden" + row;
$(thisHandle).click(function(e){
e.preventDefault();
$(thisHidden).bPopup({modalColor:"black"});
});
}
However, it appears that all the internshipHandle elements are being linked to the last internshipHidden element. What could be causing this issue? Is there a more efficient way to create modal windows from dynamically generated hidden divs within the existing framework without resorting to completely changing to Bootstrap?
Although DreamWeaver discourages placing functions inside loops, some experienced developers advise against heeding its warnings.
Edit: I attempted the same approach with jQueryUI dialog and encountered similar challenges. Any insights or explanations would be greatly appreciated. Thank you!