The popup menu with icons gives correct value back when clicking on the text
[url=https://postimages.org/][img]https://i.postimg.cc/BZD93yTy/htmlobject.png
But when clicking on the svg icon, it refers to this element and gives wrong value back.
[url=https://postimages.org/][img]https://i.postimg.cc/Sx9zfmCd/svgelement.png
How do I target the li regardless where I click on the popup menu?
[url=https://postimages.org/][img]https://i.postimg.cc/h4xjY2f4/ul.png
Live:
Here is the code behind the “button”
“`
window.addEventListener(“click”, (event) => {
const
// Provide elements being needed at first level:
row = event.target.closest(‘tr’),
id = row.dataset.id,
ulPopMore = event.target.closest(‘ul.popmore’),
ulPopStatus = event.target.closest(‘ul.popstatus’);
// Now check which element was clicked:
// Was an item in the ul for “more” clicked?
if (ulPopMore) {
const action = event.target.dataset.action;
alert(action)
switch (action) {
case “edit”:
alert(action) //<—never fires
edit(id);
break;
case “del”:
alert(action + id)
del(id);
break;
default:
alert(“wrong”)
}
}
if (ulPopStatus) {
alert(“klick ” + event.target)//random svg and li
const action = event.target.dataset.action;
alert(“action “+ action)
switch (action) {
case “0”:
alert(action)
break;
case “1”:
alert(action)
break;
case “6”:
alert(action)
break;
default:
alert(action)
alert(“wrong”)
}
}
});