Custom check dates and rollback with ajax

Hi there.

I am trying to make an ajax call when an event dragged to an another date. If new dates colliding with any of dates that i keep in db, throw and error and roll back to the original dates which i moved.

I did get original dates and new dates in event called “onBeforeEventChanged” and then tried to make an ajax call. But failed to roll back dates because the process doesn’t wait the result of the ajax call. ( i guess )

So far i’ve tried make an ajax request in “onBeforeEventChanged”, and “dragEnd” events and failed.
Is there any way to make an ajax call in any event for checking dates server side?

Hello,

You need to save new event state in the onBeforeEventChanged handler, make an ajax call and return false from the event so that Scheduler doesn’t save anything.
If check on server was successful - apply the saved changes by the code.
If you get an error from the server - show the message to the user with info about it.

Perhaps it will be easier to allow the changes be sent to the server and make check there while saving.
If an error fires during the test - return the error as a result of the action. Then catch the error on the client, show the message that something went wrong to the user and reload the Scheduler to restore the original state.