I think I found a bug in the timelineView-extension.
I wanted to add a confirm-dialog for drag-operations in my timelineView with renderMode set to “bar”. I initially used this code:
scheduler.attachEvent("onBeforeEventChanged", function (event, native_event, is_new) {
if (!is_new) { //only drag-operations
return confirm("Save new location?");
}
return true;
});This only worked partially. start_date and end_date were correctly set back to the pre-drag-values. But not the section, which was still the new value.
I eventually got a workaround by modifying my code, so that the old section gets saved at drag-start:
scheduler.attachEvent(“onBeforeEventChanged”, function (event, native_event, is_new) {
if (!is_new) { //only drag-operations
if (confirm(“Save new location?”)) {
return true;
}
else {
event.section = oldSectionID;
return false;
}
}
return true;
});[/code]
I also could reproduce the bug in /samples/06_timeline/02_lines.html, to make sure the bug wasn’t introduced with my previous customizations.
I tried to locate the error in the source-files but couldn’t find it.
First of all thank your for your valuable feedback.
We have verified this problem and it will be fixed in the upcoming version.
Most likely I will post here what should be changed to fix it (no source file as fixes will involve dhtmlxscheduler.js itself).
Following changes should be made to resolve this issue in dhtmlxscheduler_debug.js (working with the uncompressed version as it’s easier to navigate there).
At the end of the file add
scheduler._lame_copy=function(target, source){
for(var key in source)
target[key] = source[key];
return target;
};
2. Locate following string:
Unfortunately it also introduced a new bug
Normally one left-click (no double-click, no dragging) should trigger no action. But after you drag an event, choose the “no”/“abort” answer in the following confirm-dialog and the event then gets reverted to its original position, then a single left-click does trigger action, if you click the same event again. It seems, the software now thinks that this click is also a drag-operation therefore triggering the onBeforeEventChanged-listeners. This also prevents you from double-clicking the event.
I looked a bit in the code and in the function scheduler._on_mouse_up I found the following code-snippet:
if (this._drag_event._dhx_changed || [...]) {
[...]
if (!this.callEvent("onBeforeEventChanged", [ev, B, C])) {
[...]
}
}
I think the problem is your new function scheduler._lame_copy. It copies all properties of _drag_event, including “_dhx_changed”, which now is true.
I fixed this on my system by setting this property to false if the onBeforeEventChanged-listener returns false, changing: