Is there an event for detecting if selected element has changed


Have searched through the documentation, but cannot seem to find a clever approach that solves what i am trying to achieve.

Is it possible to detect whether the selected element has changed?

Or get the changed element when the diagram changes? Then i could match against the current selected element.

Any feedback is much appreciated!


The event bus is your friend:

eventBus.on('selection.changed', function(context) {
  var oldSelection = context.oldSelection,
      newSelection = context.newSelection;

  // go crazy

eventBus.on('elements.changed', function(context) {
  var elements = context.elements;

  // go crazy

Thanks Phillip!

I’ll give this a try.