Our powerful JS Calendar component


Post by smalchow »

We need to call an asynchronous function on the event 'beforeEventSave'. Depending on the functions response, the event changes should be applied or rejected. According to the documentation we need to set context.async to true and call context.finalize(false) to reject the event the event save.
Here is the code simply using setTimeout()

 async beforeEventSave({ eventRecord, source: context }) {
                    context.async = true;
                    setTimeout(() => {
                        context.finalize(false);
                    }, 5000);
                    return false;
                },

The console returns: "Uncaught TypeError: context.finalize is not a function"
Can you tell me where the error is?

Best regards


Post by Animal »

It's a Javascript authoring error. You are using the event firer, the source as the context.

https://bryntum.com/products/calendar/docs/api/Scheduler/feature/EventEdit#event-beforeEventSave


Post by smalchow »

Oh sorry, I found that example in another Forum entry and thought this was the way of going.. Directly accessing the context works fine, thank you!


Post by Animal »

Never copy/paste example code.

Read and understand it, then use the principles in your own design.


Post Reply