Hi Guys,
I was reviewing the scheduler.getEvents=function(E,D) function in dhtmlxscheduler.js as my collisions were not working as I had expected them too. If I put a breakpoint on
A.push©;
In the following section of code:
scheduler.getEvents=function(E,D)
{
var A=[];
for(var B in this._events)
{
var C=this._events[B];
if(C&&C.start_date<D&&C.end_date>E)
{
A.push(C);
}
}
return A;
};
My variables are as follows:
C.start_date = Thu Sep 9 00:00:00 UTC+1000 2010
C.end_date = Sat Sep 11 00:00:00 UTC+1000 2010
C.start_date<D = true
C.end_date>E = true
Thu Sep 9 00:00:00 UTC+1000 2010
Wed Sep 8 00:00:00 UTC+1000 2010
I casted the variables as dates, and then the collisions stopped occuring when they were not ment too:
scheduler.getEvents=function(E,D)
{
var A=[];
for(var B in this._events)
{
var C=this._events[B];
var c_start_date = new Date(C.start_date);
var c_end_date = new Date(C.end_date);
E = new Date(E);
D = new Date(D);
if(C&&c_start_date<D&&c_end_date>E)
{
A.push(C);
}
}
return A;
};
Too produce this issue, I created 3 events in any section other than the first one, then drag and dropped them too be sequential, and then it would cause the events too collide. Too do this, you must move one too the end, then move the next event before that one (the end date of the first one and the start date of the second one was the condition that was failing). There is another issue which I have noticed now that I have made the code change above. It believes that the two events are running simultaniously and pushes the next sequential event down within the section (below the previous sequential event). I believe this is being caused from variables being compared as a string rather than as a date too, in another section of code.
Hopefully this can be resolved easily and patched into the next release?
Kind regards
Greg Goldberg
P.S. I suspect there may be other places where dates are being compared as a string rather than as a date, due too intermittent behaviour such as the issue described above. Ensuring that date variables are cast as a new date variable will immediately resolve such issues.