Fixed the eventlistener
This commit is contained in:
@ -5,10 +5,10 @@ for (i=0; i<taskArray.length; i++) {
|
|||||||
|
|
||||||
const linkElement = document.createElement("div");
|
const linkElement = document.createElement("div");
|
||||||
linkElement.className = "linkElement";
|
linkElement.className = "linkElement";
|
||||||
|
const path = taskArray[i]["path"];
|
||||||
|
|
||||||
//TODO: taskArray needs to be preprocessed somehow
|
|
||||||
linkElement.addEventListener("click", function () {
|
linkElement.addEventListener("click", function () {
|
||||||
window.location = taskArray[i]["path"];
|
window.location.href = path;
|
||||||
} )
|
} )
|
||||||
|
|
||||||
const h2 = document.createElement("h2");
|
const h2 = document.createElement("h2");
|
||||||
@ -19,10 +19,4 @@ for (i=0; i<taskArray.length; i++) {
|
|||||||
h2.appendChild(link);
|
h2.appendChild(link);
|
||||||
linkElement.appendChild(h2);
|
linkElement.appendChild(h2);
|
||||||
grid.appendChild(linkElement);
|
grid.appendChild(linkElement);
|
||||||
|
|
||||||
console.log(grid.querySelectorAll(".linkElement")[i]);
|
|
||||||
grid.querySelectorAll(".linkElement")[i].addEventListener("onclick", function () {
|
|
||||||
|
|
||||||
window.location = taskArray[i]["path"];
|
|
||||||
}, false);
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user