How to Add Server-side Event Handlers to the Web2Cal Calendar to Respond to Event Changes
Event handlers can be added to the Web2Cal Calendar when an event is added, edited, moved, or deleted.
When using the Web2Cal calendar control you might want to execute server-side code for the following events:
- an event is added
- an event is edited
- an event is moved
- an event is deleted
There are no built-in hooks for these events, but you can easily define you own.
For the event added, edited, or deleted cases, you can add event handlers as follows:
Edit the UX component used to edit events and add the functions shown below to the Xbasic function declarations
function onEventDelete as v (e as p) end function function onEventUpdate as v (e as p) end function function onEventAdd as v (e as p) end function
Edit the UX component used to edit events and modify the server-side afterDialogValidate event to add calls to the onEventUpdate and onEventAdd functions. See below.
Edit the UX component used to edit events and modify the deleteEventXbasic Xbasic function by adding the following at the end of the function: onEventDelete(e)
How to Update the afterDialogValidate Event Handler Function
In the UX Component used to edit events, update the code in the afterDialogValidate event to call the onEventUpdate() function:
To handle the event is moved case, edit the Web2Cal component and add this code to the onComponentExecute server-side event:
if eval_valid("request.variables._XbasicFunction") then if request.variables._XbasicFunction = "updateEvents" then 'event was moved 'event data can be found in request.variables._calEvent_eventId, etc. end if end if