Hi Ilya,
Thank you so much for your excellent help. I figured out why my event was not being created correctly when passing in all the data. This was because I was mapping the UserId field too the event, and when I mapped the UserId field, start_date and end_date too the new event, it would cause the collision to be detected and the event to fail being created (which makes complete sense). Too resolve this, I coded my method as follows:
scheduler.form_blocks["approved_fields"].button_click=function(index, src, sec, data){
var event_data = scheduler._lightbox_out({}); // now event_data is an object with all information entered in the lightbox's fields
scheduler.cancel_lightbox(); // closing current lightbox
scheduler._drag_mode = "create";
scheduler.addEventNow({
start_date: new Date(event_data.start_date),
end_date: new Date(event_data.end_date)
});
scheduler._select_id = scheduler._drag_id;
scheduler._select_id1 = scheduler._drag_id;
var new_event = scheduler.getEvent(scheduler._lightbox_id); // scheduler._lighbox_id (or scheduler.getState().lightbox_id holds id of an event displayed in the lightbox)
new_event.rec_type = 'true';
new_event.UserId = event_data.UserId;
document.getElementById('schedUser').value = new_event.UserId;
}
My next issue was that the collision script was coded in a way that counted the collisions incorrectly when an event was created in this manner. To resolve this, I modified the onEventSave event handler (within the collission script) too the following code:
scheduler.attachEvent("onEventSave",function(id, edited_ev){
//var ev = scheduler.getEvent(id);
if(edited_ev.rec_type){
scheduler._roll_back_dates(edited_ev);
return scheduler.collision_check(edited_ev);
}
else
{
return scheduler.collision_check(edited_ev);
}
});
My next issue was that the script was incrementing the count and doing a comparison in a bad way within scheduler.collision_check. To resolve this, I modified the following code within it
for (var i = 0; i < evs.length; i++)
if (evs[i][map_to] == ev[map_to])
count++;
was changed too
for (var i = 0; i < evs.length; i++)
if (evs[i][map_to] == ev[map_to] & evs[i].id != ev.id)
count++;
and the following code within the same collision_check method was changed from
if (count > scheduler.config.collision_limit) {
scheduler._drag_event.start_date = temp_time;
ev[map_to] = temp_section;
single = false;
}
to
if (count >= scheduler.config.collision_limit) {
scheduler._drag_event.start_date = temp_time;
ev[map_to] = temp_section;
single = false;
}
Hope this helps with anyone else in the future who has similar issues. Thanks heaps for all your excellent help Ilya, it was greatly appreciated, and my issue is now resolved.
Kind regards
Greg Goldberg