Creating Task from a custom popup does not delete the "New Task" placeholder

Hello,

I have a project wherein i have 2 types of data in my Gantt.
Hence, When I click the “+” button, I show a modal choices first

[ ] Option 1
[ ] Option 2

Option 1 uses the lightbox of the dhtmlx Gantt, which works fine. (cancelling it removes the “New Task” auto generated in the Gantt)

However for Option 2, I am using a self-made ‘lighthouse’ i should say, since it has different model.
Creating and saving it is working, but when i choose to “CANCEL”, the “New Task” that is auto generated in the Gantt list is not deleted/removed automatically.

Hello Asyong,
You need to check the $new property and manually delete the task with the deleteTask method. That’s what Gantt does with the standard lightbox.
Here is an example of how it works with the custom lightbox:

function cancel() {
    var task = gantt.getTask(taskId);
 
    if(task.$new)
    gantt.deleteTask(task.id);
    gantt.hideLightbox();
}

https://snippet.dhtmlx.com/5/786a25548

1 Like