How to execute client side JavaScript function whilst server processing request after user clicks on event blocks? [DayPilot Monthly Event Calendar]
Asked by Anonymous 4 years ago.
Hi,
Just wondering is it possible to fire JS code whilst a user request (i.e. "EventClickHandling='PostBack' ", "TimeRangeSelected='PostBack' ") is being processed by the backend server?
Sometimes when the server deals with function handlers, OnEventClick(), OnTimeRangeSelected() is takes a while to deal with the request. So is there any way I can execute a JS function (that displays a custom loading spinner with a please wait caption that informs the user the loading state of the application) before the response is made by the server?
If I can get any thoughts into this, that'd be great.
Many Thanks.
Answer posted by Dan Letecky [DayPilot] 4 years ago.
You can use EventClickHandling='PostBack' and invoke the PostBack manually using eventClickPostBack() from EventClickJavaScript, after executing your code:
Similar methods exist for all other events as well.
Comment posted by Anonymous 4 years ago.
When I try clicking an event on my DayPilotMonth calendar, the following code executes the server-side function handler, `dpm_EventClick`, but does not fire the client-side function, `showLoader()` in order to display an animated loading spinner via modal window whilst the server request is happening. It seems like it is not invoking the PostBack manually from ` EventClickJavaScript="..." `
Thanks Dan, the loading spinner are showing in JS as expected before response is posted from the server whenever I select a time range or click on an existing event block. Thanks again.
Is it possible to show a loading spinner when I delete an event via `OnEventMenuClick` handler?
The following code does show the loading spinner, however the PostBack handler doesn't get fired by the server - so it's just displaying the loader infinitely.
Comment posted by Dan Letecky [DayPilot] 4 years ago.
The menu click mechanism is the same. You just need to change the Action to "JavaScript" - then it will execute the JavaScript code from the JavaScript property: