Skip to main content

checkTask()

Description

Marks a task as complete

Usage

checkTask({
id: string | number,
manual?: boolean // false by default
}): void;

Parameters

  • id - (required) the id of a task
  • manual - (optional) if true, marks the task in the "manual" mode. If false, the result of applying the method depends on the value which is specified for the behavior attribute of the selectable parameter of the taskShape property

Example

const { ToDo, Toolbar } = todo;

const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1" },
{ id: "1.1", text: "Task 1.1", parent: "1" },
{ id: "1.1.1", text: "Task 1.1.1", parent: "1.1" },
{ id: "1.2", text: "Task 1.2", parent: "1" },
]
});

const toolbar = new Toolbar("#toolbar", {
api: list.api,
});

// mark the specified task as completed
list.checkTask({
id: "1.1.1",
manual: true // 'true' - ignores the value of the "behavior" attribute of the "selectable" parameter of the "taskShape" property
});

Related article: Operations with tasks