Events trigged twice in one click

I’m having a problem that i saw before but i was not sure if it was problem in bpm,

var eventBus = bpmnViewer.get(‘eventBus’);
eventBus.on(‘’, overlayElemento);

i’m using this to trigger the event onclick and it works but sometimes the function that i’m calling on the event onclick is called twice in one click.

my function just show or hide a overlay


function overlayElemento(e) {
    if (e.element.type == 'bpmn:Task') {
        showHideOverlay( + 'data'); // id of my overlay

and showHideOverlay check if the elements exist and show or hide…
the problem is since this function is been called 2 times in one click … yes the overlay will never be showed cuz he show and than hide(in one click)
i’m not really sure why this happeneds. but is not always if I press f5 can work like i want but sometimes just dont work like i want.

Hi @gabriellpa

Check this sample.

1- Init element click event with callback function

onElementClickNotifyEvent: function(callback) {
    modeler.on('', (e) => {
        if (typeof callback === 'function') {

2- use event and callback

onElementClick: function(e) {
    // put yor code here

initializeModelerEventHandler: function() {

3- How to call??

$(document).ready(function() {

I hope helped you.

Good luck.

1 Like