Skip to main content
The Gantt fires an event for every action that occurs, whether triggered by the user or by api.exec(). You can listen to events to react to changes, or intercept them to validate and cancel operations.

Listening to events with api.on()

api.on() registers a callback that fires after an action has been applied to the state. Use it to react to changes, sync to a backend, or update external UI.
You can also handle events directly as component props using the on<ActionName> naming convention:
Event prop names are derived by removing hyphens from the action name and prepending on. For example, "add-task" becomes onaddtask.

Intercepting events with api.intercept()

api.intercept() registers a callback that fires before the action is processed. Return false from the callback to cancel the action. Any other return value (including undefined) allows the action to proceed.

Difference between on() and intercept()

Cancelling an action

Return false from an intercept callback to cancel the action. The state is not modified and no on() callbacks fire.

Grouping and removing listeners

Pass a tag to group related listeners. Call api.detach(tag) to remove all listeners in the group at once.

Available events

Every action listed in Actions is also an event. The same parameters are passed to the callback. Below is a quick reference.

Task events

View events

PRO events

Full example