"TypeError t is undefined" when I'm trying to delete a task


I wrote a function to make sure that when I delete a task, its child becomes the child of its father.
But I now have an error “TypeError t is undefined” that seems to be caused by this line :

taskChild.parent = taskParent.id;

Here is the full function :

[code] gantt.attachEvent(“onBeforeTaskDelete”, function(id,item){
var taskObj = gantt.getTask(id);
if (taskObj.parent != null && taskObj.parent > 0) {
var taskParent = gantt.getTask(taskObj.parent);
var tabchild = gantt.getChildren(taskObj.id);
if (tabchild.length > 0 ) {
var taskChild = gantt.getTask(tabchild[0]);
taskChild.parent = taskParent.id;
taskChild.start_date = taskParent.start_end;
taskChild.end_date = gantt.calculateEndDate(taskChild.start_date, taskChild.duration);
gantt.refreshTask(taskChild.id, true);
var taskParentChild = gantt.getTask(child.parent);
child.start_date = gantt.roundDate(new Date(taskParentChild.end_date.valueOf()));
child.end_date = gantt.calculateEndDate(child.start_date, child.duration);
gantt.refreshTask(child.id, true);
},taskChild.id );

	return true;

In a snippet : docs.dhtmlx.com/gantt/snippet/364d105b

What can I do to make it works?


We don’t get this error in your snippet.

Please, try to use next way:
I hope it help to solve the issue.