Skip to main content

api.on()

Description

Allows attaching a handler to the inner events

Usage

api.on(
event: string,
handler: function
): void;

Parameters

  • event - (required) an event to be fired
  • handler - (required) a handler to be attached (the handler arguments will depend on the event to be fired)
info

The full list of actions can be found here. Use the api.on() method if you want to listen to the actions without modifying them. To make changes to the actions, apply the api.intercept() method.

Example

<script>
import { getData } from "./common/data";
import { Gantt } from "@wx/svelte-gantt";

const data = getData();

let api;

$: if (api) {
api.on("delete-link", ev => {
console.log("The id of the deleted link:" (ev.id));
});
}

</script>

<Gantt
bind:api
tasks={data.tasks}
links={data.links}
//other settings />

Related articles: