onTaskCreated

fires when a user creates a new task by pressing the'+' button in a grid, or when the createTask method is called

boolean onTaskCreated(Task task);
taskTaskthe object of a new task
booleanreturning `false` will cancel the creation of a new task, returning `true` will continue the default processing

Example

gantt.attachEvent("onTaskCreated", function(task){
    task.projectId = 1;
    return true;
});

Details

The event fires before a new task is displayed, which allows you to set default values or cancel the creation of a task.

By the time this event is fired, the new task is already available in the datastore via the getTask method.

If the event handler returns false, the task will be removed from the datastore without firing the onAfterTaskDelete event.

The final order of events that fire when you create a task with the createTask method is:

  1. onTaskCreated
  2. onBeforeLightbox
  3. onLightbox
  4. onAfterLightbox
  5. onAfterTaskAdd
  6. onBeforeTaskAdd
See also
Back to top