Currently, what I’m trying to do is request a delete on server first before deleting the task on frontend but it seems it doesnt wait on the http request.
Unlike onBeforeTaskAdd which respect my http request. it will block when I have an error on the server side.
gantt.attachEvent("onBeforeTaskDelete", function (id, item) {
return axios.post('/timelines/task/' + id, {
"_method": "DELETE"
})
.then(function (response) {
return true
})
.catch(function (error) {
gantt.alert({
title: "Error",
text: "Something went wrong.",
ok: "Ok",
});
// gantt.detachEvent(attachOnBeforeTaskAdd)
// gantt.addTask(item, item.parent, item.$index)
// gantt.attachEvent(attachOnBeforeTaskAdd)
return false
})
})
that is my code and it doesn’t work as expected unlike the onBeforeTaskAdd which really block or wait for the return true or false. I also try to do async but it doesnt work also.