The jsPlumb Toolkit offers a comprehensive set of events to which you can subscribe. These are broadly broken up into two categories - events fired by each Toolkit instance, which are events related to the underlying Graph, and presentation-level events - those fired by the Surface component, either from a
bind on the Surface or via event registrations in its View.
Several events - such as node addition/removal etc - are fired by both the Toolkit and any associated Surfaces, but the arguments passed to your callback differ slightly: events fired by Surfaces contain DOM elements along with Toolkit objects, whereas Toolkit events pass strictly Toolkit objects.
You bind to events on an instance of the jsPlumb Toolkit with the
|dataLoadStart||Notification that loading of a dataset by the Toolkit instance has begun. This event is fired at the beginning of the `load` method.||-|
|dataLoadEnd||Notification that loading of a dataset by the Toolkit instance has been completed. Fired at the end of the `load` method.||-|
|dataAppendStart||Notification that incremental loading of a dataset by the Toolkit instance has begun. This event is fired at the beginning of the `append` method.||-|
|dataAppendEnd||Notification that incremental loading of a dataset by the Toolkit instance has been completed. Fired at the end of the `append` method.||-|
|graphCleared||Notification that the underlying graph was cleared.||-|
|graphChanged||Notification that the underlying graph was changed.||-|
|nodeAdded||Notification that a new node has been added to the data model||
|nodeRemoved||Notification that a node has been removed from the data model.||
|edgeAdded||Notification that a new Edge has been added to the data model.||
|edgeRemoved||Notification that an Edge has been removed from the data model.||
|edgeTarget||Notification that the target for some Edge has changed.||
|edgeTarget||Notification that the source for some Edge has changed.||
|portAdded||Notification that a Port has been added to some Node.||
|portRemoved||Notification that a Port has been removed from some Node.||
|groupAdded||Notification that a new group has been added to the data model.||
|groupRemoved||Notification that a group has been removed from the data model.||
|nodeUpdated||Notification that the data for some Node has changed. Fired as a result of calling `updateNode` on an instance of the Toolkit.||
|edgeUpdated||Notification that the data for some Edge has changed. Fired as a result of calling `updateEdge` on an instance of the Toolkit.||
|portUpdated||Notification that the data for some Port has changed. Fired as a result of calling `updatePort` on an instance of the Toolkit.||
|dataUpdated||Notification that the data for some object has changed. This event is fired after any - and all - other event that has modified the data.||-|
|group:addMember||Notification that a node was added to a group||
|group:removeMember||Notification that a node was removed from a group||
An instance of the Toolkit instance may have zero or more Surfaces attached to it. The Surface widget fires a number of events that you can listen to in order to hook into the rendering process. For instance, you might subscribe to the
nodeAdded event in order to attach behaviour to each of your nodes as they are drawn on screen. Or you might subscribe to
edgeAdded in order to be able to take action when a user has established a new connection using the mouse.
Many of these events are re-posted Toolkit events, and for these you can choose to subscribe on either the Toolkit instance or on each Surface. The difference is that when you subscribe to a Surface's version of these events, you will often also get an associated DOM element, which can be useful.
Note the vast majority of events pass a single argument -
params - to your listener, so the parameter lists refer to the possible properties in that object. Where an event differs you will see the difference in the callback's method signature.
Events on the Surface widget are discussed in detail in the Surface widget documentation.
view parameter you supply to a
render call, you can register events in Node, Port and Edge definitions. This is discussed in detail in the Surface widget documentation.