I am trying to create a dialog that displays a larger version of the clicked image from a gallery of many more images. So far, I have used MDC-web components and Java-script to successfully open the dialog of the specific image clicked (the image is basically a card with the actual image as its background) however, when I try and close the dialog, it won't close.
Below is the javascript code:
let dialog; const dialogs = document.querySelectorAll('.mdc-dialog');
for(let i =0; i<dialogs.length; i++){
dialog = new mdc.dialog.MDCDialog(dialogs[i]);
//console.log(dialog);
const cardClicked = dialogs[i].parentElement;
console.log(cardClicked);
cardClicked.addEventListener("click",(event)=>{
if(dialog.isOpen){
console.log(dialog.open)
dialog.close();
}else{
console.log("open ish--> is open is false");
dialog.open();
console.log(dialog);
}
});
}
If there is anyway, that you can help me resolve the issue that would be much appreciated. Thanks.