I am creating events programmatically via javascript by calling scheduler.addEvent. I am able to create events fine this way. I’d like to be able to detect collisions on events created this way, but I’m not sure how. I have the collision code added and working as it does not allow me to create events via GUI that “collide”.
Can someone share the code I would need to use to detect a collision when adding events programmatically?
Basically, what I want is:
If an event that is going to be created will collide with an existing event, an alert will popup letting user know and new event will not be created.
I did and do have code setup for the onCollision event. The code fires only when I create an overlapping event via drag-n-release (GUI). It does not fire when the event is created with the scheduler.addEvent code.
From what I understand, addEventNow triggers the lightbox. What if I wanted to just detect collisions without any user intervention?
Also
var collision = scheduler.callEvent("onBeforeEventChanged", [scheduler.getEvent(id)]);
which will return true if there is no collision, or false in case of collision
returns true regardless of whether there’s any collision.
var collision = scheduler.callEvent(“onBeforeEventChanged”, [scheduler.getEvent(id)]);
This line do not check all events for collision, but only the one which id is used in the command.
Also, be sure that you have included ext/dhtmlxscheduler_collision.js
That is very strange as the exact same code shows me true, regardless.
And based on the start date and end dates in your code segment, shouldn’t the correct response be that the collision is true since there is indeed a collision?
That’s indeed a collision and that’s why “onBeforeEventChanged” returned “false”. If everything would be alright = no collision it would return “true”.
Do you have “onEventCollision” set up with your own handler?
The same code correctly detects collision for version 3.0 locally.
If you are using 3.0 and sample still occurs - please provide any kind of sample or demo link where issue can be reconstructed.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan