beforeChange event of checkbox in form does not cancel change with asynchronous function

I have a form with a checkbox, which I implement the beforeChange event to execute a function with asynchronous return. While doing tests, I realized that if the function returns false that it should cancel the checkbox change, it doesn’t work correctly.

If the function is not asynchronous, everything works correctly, but I need it to work this way. Is there any way to make this work, or would it be a problem with the suite’s execution of the event?

Here is an example with the situation I mentioned:
https://snippet.dhtmlx.com/7uzeqw5z

How did you solve it?

Hello, I don’t remember exactly because it’s been a year, but if I’m not mistaken I didn’t solve it directly. In this case, I rewrote all the validations and adapted the business logic so that it did not work asynchronously - in my case this was possible.

However, unfortunately I don’t know how to solve it, if we can solve it, I believe that the form has to be modified internally to do so.

One way I had thought of to try to get around this would be, within the event, you make your asynchronous call, and then you return false, canceling the box’s state change. and when your call ends, at the end you could update the checkbox state manually, controlling the execution of the beforeChange event through a flag. But for it to work, you need to remove async from the beforeChange event implementation function, because even if it is done this way, if you have async, the box’s state change is not stopped, not even if it explicitly returns false.

Here’s an updated example of how to do this:
https://snippet.dhtmlx.com/esfkldpu

I hope this can help you.

Hello, thank you for your help.
yesterday, I tried to modify the source code.
I got this.

I define it myself in the code
(gantt.onBeforeMouseDown2Drag)