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 "wx-svelte-gantt";

const data = getData();

let api;

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

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

<div>
<button on:click="{stop}">Stop logging</button>
</div>

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

Related articles: How to access Gantt API