DHTMLX / scheduler

GPL version of JavaScript Event Scheduler
https://dhtmlx.com/docs/products/dhtmlxScheduler/
GNU General Public License v2.0
311 stars 110 forks source link

'onEventCreated' event fired even when user has not ended dragging #40

Closed ohchiko closed 6 years ago

ohchiko commented 6 years ago

Case: I want if user drag on empty date (create new event obj) redirect to another page.

Problem: When user drag on a date, then when moving to the next date, this method already fired, even the drag is not yet done (the user still dragging). So then the user redirected already and I can't get the correct 'end_date'.

How to achieve: I click and hold on May 10, then I want to move my mouse to May 15, but when I pass May 11 'onEventCreated' fired.

Expected: The user gets redirected after the drag is ended.

AlexKlimenkov commented 6 years ago

Hi, it is an expected behavior. onEventCreated is fired when the new event object is initialized and usually serves as an entry point for default values of an event object.

Usually, it's onEventAdded event that signals that new entry has been added and needs to be saved to the backend. It is fired when event creation is finalized - user finished drag and drop and confirms changes in the details form or in the inline editor, so probably it's not what you need. In your case you can try using onDragEnd instead: http://snippet.dhtmlx.com/f1cf11bfc https://docs.dhtmlx.com/scheduler/api__scheduler_ondragend_event.html

If you want to use a separate page instead of built-in lightbox, you can use onLightbox/onBeforeLightbox events and redirect from them: http://snippet.dhtmlx.com/ecf47de40 https://docs.dhtmlx.com/scheduler/api__scheduler_onlightbox_event.html

And in order to detect when a new entry is being created using scheduler.getState method: https://docs.dhtmlx.com/scheduler/api__scheduler_getstate.html