Fixed the eventlistener

This commit is contained in:
2020-01-30 16:43:35 +01:00
parent be36d3382b
commit 73dcbe5842

@ -5,10 +5,10 @@ for (i=0; i<taskArray.length; i++) {
const linkElement = document.createElement("div");
linkElement.className = "linkElement";
const path = taskArray[i]["path"];
//TODO: taskArray needs to be preprocessed somehow
linkElement.addEventListener("click", function () {
window.location = taskArray[i]["path"];
window.location.href = path;
} )
const h2 = document.createElement("h2");
@ -19,10 +19,4 @@ for (i=0; i<taskArray.length; i++) {
h2.appendChild(link);
linkElement.appendChild(h2);
grid.appendChild(linkElement);
console.log(grid.querySelectorAll(".linkElement")[i]);
grid.querySelectorAll(".linkElement")[i].addEventListener("onclick", function () {
window.location = taskArray[i]["path"];
}, false);
}