onBeforeTaskChanged

fires after the user has finished dragging and released the mouse button but before the changes are applied

boolean onBeforeTaskChanged(string|number id,string mode,object task);
idstring|numberthe task id
modestringthe drag-and-drop mode ("resize", "progress", "move", "ignore")
taskobjectthe copy of the task object in its original state (before drag and drop)
booleandefines whether the default action of the event will be triggered (true) or canceled (false)

Example

gantt.attachEvent("onBeforeTaskChanged", function(id, mode, task){
    //any custom logic here
    return true;
});

Details
  • The event fires when the user drags a task in the timeline area.
  • The event is blockable. Return false to cancel the drag operation.
  • The event fires before the onAfterTaskDrag event.

The task argument contains the original (not modified) task object, while the same data object available via the gantt.getTask(id) method is already modified. This object can be used to check the exact changes made by drag and drop compared to the initial state of the task - e.g. whether duration increased or decreased, start date moved forward or backward, etc.
If false is returned from the method, the task object in gantt will rollback to the values from the original task object.

See also
Back to top