preSubmit not cancelling when returning false from an async/await handler
preSubmit not cancelling when returning false from an async/await handler
It seems that an async/await handler is not an expected argument for event handlers; e.g.
editor.on("preSubmit", async () => {
try {
return (await jQuery.ajax(...)) as boolean;
} catch (e: any) {
alert(e);
return false;
}
});
Is this type of programming structure acceptable when using event handlers?
Answers
I would expect that to work okay. I've just tried making a little example and it works okay.
Can you link to a test case showing the issue please? Also, what version of Editor are you using?
Allan
Hi Allan,
Our company is using DataTables Editor v2.4.0.
I have also looked at your example and it doesn't replicate the scenario I'm concerned with. Perhaps I wasn't clear in the description.
In the scenario that I having problems with is that the async/await handler is returning
falseto cancel the submit process. It doesn't cancel the submit process, but instead cycles to run the async/handler again. It gets into an endless loop.A promise that resolves to
falseshould still work okay - here is my example updated to show that.I've just had a look at the 2.4.0 code and there hasn't been any changes in that section between it an 2.5.0, so it should work there.
Are you able to modify my example to demonstrate the problem or give me a link to a test case showing the issue?
Thanks,
Allan