Duplicated Tasks's Events in React/Meteor

I was able to implement the component in React (with Meteor, React Router) and it was great. However, I have a big problem: every time I leave the gantt and to go to another module and then return, the events of the tasks (add, modify, delete, etc) are doubled or tripled.
The steps would be the following:

  1. I use the gantt perfectly.
  2. I click on my options menu and I go to another module.
  3. Return to the Gantt and try to modify a task: the modify event is executed 2 times.
    The events are duplicated as many times as clicks have done in other modules!


The cause of the issue could be multiple initialization of Gantt on the page and that you hang events handlers each time.
I.e. if you for example show Gantt in container that can be opened/closed(when you go to anothe module), each time when user open it, you initialize gantt and add events:

gantt.attachEvent("onTaskDblClick",.....) gantt.init("gantt_container")

The Gantt instance you open each time is the same one, so, each time when you add onTaskDblClick - new handler is added and the previous ones also still exist. This is the cause why event is getting fired more than once. You have multiple the same event’s handlers and they fire several times.

To solve it, you should add events only one time after the first initialization of gantt.