I’m having this issue in my To-Do-List project. When creating a task in one of the projects the task wont appear, even though the id is the same and the array is populated? In AllTask, Important, Checked or Today the tasks will appear. For the task to appear again I have to refresh the page anyone knows why this happenes? Here’s the code:
import RenderTasks from './renderTasks';
const tasksWindow = document.querySelector('.tasks');
const taskForm = document.querySelector('.taskWindow');
let taskArray = [];
export default function renderPage(name, id){
taskArray = JSON.parse(localStorage.getItem("taskList"));
console.log(taskArray);
while(tasksWindow.firstChild){
tasksWindow.removeChild(tasksWindow.firstChild);
}
const title = document.createElement('h1');
title.classList.add('tasksTitle');
title.textContent = name;
tasksWindow.appendChild(title);
const gridContainer = document.createElement('div');
gridContainer.classList.add('taskGrid');
tasksWindow.appendChild(gridContainer);
const addTask = document.createElement('button');
addTask.classList.add('addTask');
addTask.textContent = '+';
tasksWindow.appendChild(addTask);
addTask.addEventListener('click', (e) => {
taskForm.style.display = 'flex';
add.style.display = 'flex';
editAdd.style.display = 'none';
});
taskArray.forEach(element => {
if(element.parent == id){
RenderTasks(element.title, element.description, element.priority, element.dueDate, element.checked);
}
});
}
What’s going on->
I really can’t figure anything out I think it’s something related to the = sign but I don’t know.