getGanttInstance Undo event lost

<script src="/dhtmlxgantt_undo.js"></script>

var tab_gantt =  Gantt.getGanttInstance();


Undo event lost why?

Hi @nidemifan,
Could you please clarify what did you mean as Undo event lost?

The issue could have occurred if you create a new instance of gantt:
var gantt = Gantt.getGanttInstance() and try to call gantt.undo() just after that, before initializing this new instance: gantt.init() .
After creating a new instance of gantt, the old instance will terminate to exist and will lose all event handlers and configurations. The new instance will partly work before initialization, but undo extension will not have a connection with it, so after creating the new instance of gantt, you have to initialize it( gantt.init()) and parse data. After that, all should work correctly.

I made a little snippet, where you can see how undo/redo functionality could work with more than one instance of gantt:
Main steps of this solution, to make this snippet more clear:

  1. Add the link to the dhtmlxgantt_undo.js
  2. Create 2 instances of gantt (gantt1, gantt2), like in this fragment:
    var gantt1 = Gantt.getGanttInstance ();
    var gantt2 = Gantt.getGanttInstance ();
  3. Create undo and redo buttons for each instance, like in this fragment:
    <input value =" Undo1 "type =" button "onclick = 'gantt1.undo()'>
  4. After calling gantt2.init() add a task gantt2.addTask ({... id4})

To make this snippet more demonstrative, I called gantt2.undo() inside setTimeout function to remove the added task after 5sec.

For now, I can’t answer exactly what is the issue without more details. Could you please reproduce your issue in the following snippet:
Click the share button and send me the link?