onBeforeTaskUpdate
Description
Fires before the user updates a task
onBeforeTaskUpdate: (id: string | number, new_task: Task) => void;
Parameters
id- (required) string | number - the task idnew_task- (required) Task - the new (updated) object of the task
Example
gantt.attachEvent("onBeforeTaskUpdate", function(id,new_task){
//any custom logic here
});
Details
While using the onBeforeTaskUpdate event, it is not always possible to get the object of the task before the task is completely updated. The event fires after the task object has been updated but before all changes have been applied. To get the task object before the changes are applied, you need to use the event handlers which are directly related to the changes of the task:
If the changes are made via API, you may get the task object before the code, which modifies the task, is executed. Check the example where you may modify a task in different ways (for instance, change the task dates):
sample: Updating a task
After comparison, you will notice that the events, which fire right before you modify the task, return the old task object, while the onBeforeTaskUpdate event returns a new object of the task.