Skip to main content

api.detach()

Description​

Allows removing/detaching action handlers

Usage​

api.detach(tag: number | string ): void;

Parameters​

  • tag - the name of the action tag

Example​

In the example below we add an object with the tag property to the api.on() handler, and then we use the api.detach() method to stop logging the open-task action.

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

const data = getData();

function init(api) {
api.on(
"open-task",
({ id }) => {
console.log("Opened: " + id);
},
{ tag: "track" }
);
}

function stop() {
api.detach("track");
}
</script>

<div>
<button onclick={stop}>Stop logging</button>
</div>

<Gantt tasks={data.tasks} links={data.links} {init} />

Related article: How to access Gantt API