Should callback with the current drag dates in onBeforeTaskChanged


#1

Under some situations , I have to decide should the dates of task be changed or not, but I couldn’t get the current dragging dates from the params that onBeforeTaskChanged give me ,I could only get the original task from it, could you guys pass the current dragging dates from onBeforeTaskChanged?


#2

Hi @kevinyaoooooo !

The task object inside gantt is already modified when onBeforeTaskChanged is called. So you can get the current task values using gantt.getTask(id):

gantt.attachEvent("onBeforeTaskChanged", function(id, mode, task){
   var currentTask = gantt.getTask(id);// current dragging dates
   // task - original task dates

   ///...

});

Please check this sample:

It may be a bit different from what you’re doing but should be illustrative enough. It’s a demo I’ve made when I needed to show confirmation popups after drag and drop, the current task dates inside the onBeforeTaskChanged were needed to confirm the action.