Skip to main content

uncheckTask()

Description

Marks a task as incomplete

Usage

uncheckTask({
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 completed parameter of the taskShape property

Example

Example 1. Unchecking one task
const { ToDo, Toolbar } = todo;

const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1 #tag1" },
{ 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 task as completed
list.checkTask({
id: "1.1.1",
});

// mark the specified task as uncompleted
list.uncheckTask({
id: "1.1.1",
manual: true // 'true' - ignores the value of the "behavior" attribute of the "completed" parameter of the "taskShape" property
});
Example 2. Unchecking multiple tasks
const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1" },
{ id: "1.1", text: "Task 1.1", parent: "1", checked: true },
{ id: "1.1.1", text: "Task 1.1.1", parent: "1.1", checked: true },
{ 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", checked: true },
],
selected: ["1.1", "2.2"],
});

// uncheck selected tasks
list.eachSelected(id => {
list.uncheckTask({ id });
}, true);

Related articles: