Search
Diagram Events

There are various events raised after user interaction in JsDiagram. These events are accessible as static properties of the Events class. Event listeners are attached to a Diagram instance through the addEventListener method.

The following sample code attaches an event listener to the nodeCreated event. The variable diagram identifies a Diagram object and onNodeCreated is the name of the listener function.

JavaScript  Copy Code

// a shortcut to the Events class
var Events = MindFusion.Diagramming.Events;

// add the listener
diagram.addEventListener(Events.nodeCreated, onNodeCreated);

The declaration of all event handlers should look similar to the following, with a sender event specifying the diagram, and an args argument that is an instance of either NodeEventArgs or LinkEventArgs:

JavaScript  Copy Code

function onNodeCreated(sender, args)
{
    // ...
}