if you modify the sample: 05_leading_mysql.html and add this line:
scheduler.attachEvent("onBeforeEventDelete", function(event_id,event_object){
alert('i am clicked');
return false;});
before (I don’t know where else to put it)
[code] scheduler.init(‘scheduler_here’,null,“month”);
scheduler.load(“php/events.php?uid=”+scheduler.uid());
var dp = new dataProcessor("php/events.php");
dp.init(scheduler);[/code]
the alert triggers twice, and even there is a return false, the event is deleted in the database (although it is not removed from te calendar until you refresh)
I’m using firefox 3.5.7 if that matters …
This is expected behavior, when dataProcessor is used - it attaches handler to the onBeforeEventDelete as well, which causes double activation of handler.
If you want to control delete operations through onBeforeEventDelete handler - you must not use dataprocessor.
If it is expected, why doesn’t it trigger twice on onEventAdded and on onEventChanged ?
shouldn’t there be a distinction between custom events and build in events ?
Actually deleteItem method is called twice if DataProcessor is enabled:
- user press delete button (deleteItem is called):
an event isn’t deleted in scheduler, but request for deleting goes to the server
- if the server response confirms deleting operation for this event, the deleteEvent method is called again to delete event in scheduler.
It is called onBeforeEventDelete (before the item gets deleted) so before there is a call to the server.
According to the manual:
onBeforeEventDelete: blockable, occurs after user clicks on delete button (in event bar or in details window)
What does ‘blockable’ mean then ?
If you are using scheduler without dataprocessor - it works exactly as described - event handler will be called before deleting and based on its result the event will be deleted or will not be deleted.
DataProcessor is a standalone component, and when you are enabling it, logic of actions changes a bit, because DataProcessor uses the same public handler for delete-action detection.
- dataprocessor reacts on onBeforeEventDelete - server action send
- scheduler call your custom onBeforeEventDelete action
There is no way to block dataprocessor from your custom onBeforeEventDelete
I don’t know how much I broke the script, but if you add this code (line 3413) which I copied from the onEventCancel event
case "dhx_delete_btn":
if (scheduler.checkEvent("onBeforeDelete") &&
!scheduler.callEvent("onBeforeDelete",[scheduler._lightbox_id,scheduler._lightbox_out({})]))
{
scheduler.hide_lightbox();
break;
}
you can actually cancel the event.
(dhtmlxscheduler_debug.js)
As far as I can see, the above code update must not have any side effects,
not working for me… I have used latest version of dhtmlxscheduler.