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 setup>
import { getData } from "./common/data";
import { Gantt } from "@svar-ui/vue-gantt";

const data = getData();

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

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

<template>
<div>
<button :onclick="stop">Stop logging</button>
</div>

<Gantt :tasks="data.tasks" :links="data.links" :init="init" />
</template>

Related articles: How to access Gantt API