Skip to main content

beforeAdd

fires before adding an item

beforeAdd: (newItem: any) => boolean | void;

Parameters:

  • newItem: object - the object of an added item

Returns:

Return false to prevent adding an item into a data collection; otherwise, true.

Example

diagram.events.on("beforeAdd", function(id){
if (some_check)
return false;
return true;
});

Related sample: Diagram. Org chart mode. Events

Returning false from the event handler will prevent item adding.