Skip to main content

setConfig()

Description

Sets a new configuration for the To Do List

Usage

setConfig(config: object): void;

Parameters

  • config - (required) an object with new configuration of To Do List. See the full list of properties here
tip

The method changes only the parameters you passed. It is also possible to load data into the To Do List via the method, but we recommend that you use the parse() method for this purpose.

important

The setConfig() method destroys the current component and initialize a new one. If you use the component with Toolbar, you need to call the setConfig() method of Toolbar, because it uses the internal API of To Do List. See the example below!

Example

const { ToDo, Toolbar } = todo;

const list = new ToDo("#root", {
projects: [
{ id: "first", label: "First project" },
{ id: "second", label: "Second project" },
{ id: "third", label: "Third project" },
],
activeProject: "first"
});

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

// change configuration of To Do List
list.setConfig({
activeProject: "second"
});

// update configuration parameters of Toolbar
toolbar.setConfig({
api: list.api,
});