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 taskmanual
- (optional) iftrue
, marks the task in the "manual" mode. Iffalse
, the result of applying the method depends on the value which is specified for the behavior attribute of the completed parameter of the taskShape property
Example
Example 1. Checking one task
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 "completed" parameter of the "taskShape" property
});
Example 2. Checking multiple tasks
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" },
{ id: "2", text: "Task 2" },
{ id: "2.1", text: "Task 2.1", parent: "2" },
{ id: "2.1.1", text: "Task 2.1.1", parent: "2.1" },
{ id: "2.2", text: "Task 2.2", parent: "2" },
],
selected: ["1.1", "2.2"],
});
// check selected tasks
list.eachSelected(id => {
list.checkTask({ id });
}, true);
Related articles: