onBeforeEventDelete called twice?

While working with the calendar I noticed that onBeforeEventDelete events is called two times.

For example i added the following code to 01_initialization_loading/05_loading_database.html sample:

scheduler.attachEvent("onBeforeEventDelete", function(event_id,event_object){ console.log("onBeforeEventDelete"); return true; });

after clicking delete button (in lightbox or event bar) The results are: onBeforeEventDelete POST http://localhost/dhtmlx/samples/01_initialization_loading/data/events.php?editing=true 200 OK onBeforeEventDelete

This is by design or I’m doing something wrong?
Since I’m using onBeforeEventDelete to backup the event data (in case delete operation fails I’m able to restore it) I would expect to be called only once.

Thanks!

Hello,
confirmed, first time event is called before sending ‘delete’ request to the server. Second time it happens after receiving server response with confirmation of delete operation, right before remove event from the calendar.
I need some time to check, whether it’s expected to work that way

I was having the same issue…

onBeforeEventDelete(string id, event e){ ... };

I’ve notice that when the scheduler trigger the method, the property event.!nativeeditor_status appears, with “true_deleted” value.

event.!nativeeditor_status = true_deleted

Could this property be used as a way to know the handle of the method?

As Alexandra said in this post, first time is called by the dataprocessor to make server changes and the second one is called by the scheduler to change UI.

viewtopic.php?f=6&t=12049

Scheduler 4.0 has one extra event - onConfirmedBeforeEventDelete - it occurs only once, after event deleted in DB in in scheduler’s UI.

docs.dhtmlx.com/scheduler/api__s … event.html

Hi Stanislav,

Thanks for your support, but I’m not getting that behaviour you mention.
It continues been called twice using onConfirmedBeforeEventDelete, but the event.property now is set as following:

1st call // DataProcessor

e.!nativeeditor_status = [b]delete[/b]; e._text_style = text-decoration : line-through;

2nd call // Scheduler [at this moment the row has been deleted on the DB, so any server side logical could have problems if refers to the almost deleted row]

e.!nativeeditor_status = [b]true_delete[/b]; e._text_style = text-decoration : font-weight:normal; text-decoration:none;

Please ignore my previous reply.
You are right, onConfirmedBeforeEventDelete was added because of different reason, and will not help in this situation.

Try to update dhtmlxscheduler with attached one.
New version must generate only one call of onBeforeEventDelete handler.
dhtmlxscheduler_fix8.zip (30.3 KB)

Thanks ! it’s work for me.