How to check if scheduler lightbox is still open?

I have a full customized lightbox for my scheduler. I attached event on event collision.

scheduler.attachEvent("onEventCollision", function (ev, evs) {
            var c = 0, l = scheduler.config.collision_limit;
            var patientId = ev.PatientId == '' ? '0' : ev.PatientId;
            for (var i = 0; i < evs.length; i++) {
                if ((ev.UserId == evs[i].UserId) && ev.id != evs[i].id) //&& patientId == evs[i].PatientId
                    c++;
            }
            //validateOverlappingEvent();
            if (c < 1) {
                return true;
            } else {
                if (confirm("This appointment has conflict with other scheduler.\nAre you sure you want to double book?")) {
                    var x = 0;
                    for (var a = 0; a < evs.length; a++) {
                        if ((ev.UserId == evs[a].UserId) && ev.id != evs[a].id && patientId == evs[a].PatientId)
                            x++;
                    }
                    if (x < 1) {
                        return false;
                    } else {
                        validateOverlappingEvent();
                        return true;
                    }
                } else {
                    return true;
                }
            }
            //return !(c < l);
        });

Everytime I create or edit an event which has conflict to other event this will prompt user. The problem is when the user create a new event or edit existing event and choose start date and end date that conflict to other event and saved it, it still prompt the user and when the user choose to cancel the double booking the lightbox close. To prevent this I need to know if the lightbox is still open or not.

Is there any way to check if the lightbox is still open or not?

You can check

if (scheduler.getState().lightbox_id) alert("Lightbox is open");

How can I prevent lightbox from closing?
I was trying to prompt user when creating a new event which has conflict to other event. If the user don’t want to continue, the lightbox should not be closed and save the current data.

Does anyone knows how to achieve this?

That is default logic of lightbox, if you are using collision extension and during data saving collision is detected, event saving will be stopped and lightbox will stay opened.

When using onEventCollision handler, be sure to return true from it, to confirm default behavior. Returning false ( or not having return at all ) will mark collision as not-significant, and lightbox will be closed.

I tried to use the onEventCollision handler but still the scheduler lightbox close.
Any help is highly appreciated.

Can you provide any kind of sample or demo link ?
Using onEventCollision in local samples block lightbox closing as expected ( you are using scheduler 3.7, right ? )

Thank you Stanislav for fast response!

I already figured it out. I’ve created a workaround. Instead of using the onEventCollision, I already trap the collision before saving.

But I have another question, is onEventCollision not applicable in monthly and weekly view? If so, how can I manage the collision in monthly and weekly view?

In fact - onEventCollision is applicable for all views. ( it works with data objects and don’t relay on visual event representation )

If issue still occurs - please provide any kind of sample or demo link where it can be checked.

Hello,

Why is it that when I’m in monthly view or weekly view the onEventCollision behave differently? It still show the lightbox even though I return true. But when I’m in daily view, it doesn’t show the lightbox when I return true.

I hope you can help me with this.

It still show the lightbox even though I return true.
Can you provide any kind of sample or demo link where it can be checked ?

Hi Stanislav

Can i get all events between two dates without using SchedulerCalendar .

Hi,
on the client-side you can use this method
docs.dhtmlx.com/scheduler/api__s … vents.html

Hi Aliaksandr ,

I asked about how to get events without using scheduler :frowning: server side (not client)

Hi,
try using this method scheduler-net.com/docs/recurring … ing_events it can be used for regular events as well as for recurrings