I am not sure how to prevent bubbling of js popup window. I made an a tag button with onClick event that leads to a delete function for removing images. When I click the button, popup closes really fast and the delete function often doesn't execute till the end.
let image_popup = document.querySelector('.image-popup');
document.querySelectorAll('.images a').forEach(img_link => {
img_link.onclick = e => {
e.preventDefault();
let img_meta = img_link.querySelector('img');
let img = new Image();
img.onload = () => {
image_popup.innerHTML = `
<div class="con responsive3">
<h3>${img_meta.dataset.title}</h3>
<p>${img_meta.alt} autor: ${img_meta.dataset.alt2}</p>
<img src="${img.src}" class="responsive2" width="${img.width}" height="${img.height}">
<a href="" onClick="brisanje_slike(${img_meta.dataset.id})" class="trash" title="Obriši sliku"><i class="fa fa-trash fa-xs"></i></a>
</div>
`;
image_popup.style.display = 'flex';
};
img.src = img_meta.src;
};
});