adds a new task and opens the lightbox to confirm

string| number createTask( [object task,string | number parent,number index] );
taskobjectoptional, the task object
parentstring | numberoptional, the parent's id
indexnumberoptional, the position the task will be added into (0 or greater)
string| numberthe task's id


var taskId = gantt.createTask({
    text:"Task #5",
}, "project_2", 2);


If you set the index parameter with the value from 0 and greater, a task will be added to the specified position in the branch. Otherwise, the task will be added to the end of the tasks' branch.

The method invokes the onTaskCreated event. Note, the event fires before the new task is added to the dataset that allows you to cancel saving of this task at all,for example, if the user clicks 'Cancel' button in the lightbox.

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

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