Hello,
I am having some trouble regarding Custom Lightboxes.
What I want to do is:
- If the DataAction returned via the Save action is of the type “error”, display the error message in an alert window
- When the user closes the alert window, re-open the Lightbox so they can fix the error and save again, or just cancel
The issue I am facing is as follows:
- When the user creates an event and clicks “Cancel” before clicking “Save”, the event is deleted from the Scheduler - this is good
- When the user creates an event and clicks “Save”, the server returns an error, which is displayed in an alert window, and the Lightbox re-opens. If they then click “Cancel”, the event remains on the Schedule - I need it to be deleted, the same as if they had never clicked “Save”
To re-open the Lightbox, I use the following:
function postInit() {
var restoreLightbox = false;
scheduler.dataProcessor.attachEvent("onAfterUpdate", function (event_id, action, new_event_id, response) {
if (action == "error") {
restoreLightbox = event_id;
dhtmlx.message({
title: "Error",
type: "alert-error",
text: response.text || response.textContent,
callback: function () {
if (restoreLightbox) {
scheduler.showLightbox(restoreLightbox);
restoreLightbox = false;
}
}
});
}
});
}
This method is assigned to the Scheduler via:
sched.AfterInit.Add("postInit();");
I set my custom form as the Lightbox via:
sched.Lightbox.SetExternalLightboxForm(...);
I am fairly new to using this control, so I imagine I am missing something fairly simple. Any help would be greatly appreciated.
Thank you.