onAfterTaskAdd is called twice


I’m having trouble with my Gantt right now.
I implemented onAfterTaskAdd event in order to create an entry in my database for the task.
However, I noticed that the onAfterTaskAdd is called twice.

I made a temporary fix that checks if it is the 2nd call and invoke the API but I think this should not be the case.

Anyone experienced this?

Hello All,

I solved the issue.

This is because of the DHTMLX gantt being a static object.
I used the gantt in two of my components and attached events for the onAfterTaskAdd is implemented in those 2 components resulting for it to be “activated twice”.

I detached the events before adding the events on both components and now it works fine.