Commit 6a1a87a4 authored by Milan Iliev's avatar Milan Iliev

Refactored addButton into controller

parent 413e57b8
import Task from "./tasks/task.js"
import TaskController from "./tasks/controller.js" import TaskController from "./tasks/controller.js"
let task_controller = new TaskController() let task_controller = new TaskController()
task_controller.refresh()
let addButton = document.querySelector('#add_button') \ No newline at end of file
let main = async () => {
addButton.addEventListener("click", () => {
task_controller.addTask(new Task({done: false, description: "New Task"}))
})
task_controller.refresh()
}
main()
...@@ -9,6 +9,11 @@ class TaskController { ...@@ -9,6 +9,11 @@ class TaskController {
this.list_element = document.querySelector("task-list") this.list_element = document.querySelector("task-list")
this.detail_view = new DetailTaskView(document.querySelector("task-detail")) this.detail_view = new DetailTaskView(document.querySelector("task-detail"))
this.addButton = document.querySelector('#add_button')
this.addButton.addEventListener("click", () => {
this.addTask(new Task({done: false, description: "New Task"}))
})
} }
addTask(task){ addTask(task){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment