Skip to main content

add-link

Description

Fires when adding a link

Usage

"add-link": ({
id?: string | number,
link: object;
}) => boolean|void;

Parameters

The callback of the add-link action takes the next parameters:

  • id - (optional) the id of a link that is automatically generated
  • link - (required) the link object with the following parameters:
    • source - (required) the source task ID
    • target - (required) the target task ID
    • type - (required) the link type; possible link type values:
      • e2s - "End-to-start"
      • s2s - "Start-to-start"
      • e2e - "End-to-end"
      • s2e - "Start-to-end"
info

For handling the actions you can use the Event Bus methods

Example

In the example below we use the api.intercept() method to change the link variable value replacing it with the relevant data from the add-link action:

<script>
import { getData } from "./common/data";
import { Gantt } from "wx-svelte-gantt";
const data = getData();

let link;
let api;

$: if (api) {
api.on("add-link", data => {
link = data.link;
});
}

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

Related articles: How to access Gantt API