Double-Clicking on an Event = Create New Event Possible?

Hi,
I’m using a kind of fake event designed to represent availability slots. As such, I’d like users to be able to create events by double-clicking on them in the same way that one can double-click on empty portions of the calendar. I had thought this would be a relatively simple process but it’s turned out to be surprisingly difficult. I had tried using jQuery:

jQuery('.counseling_slot').live('dblclick', function(e){ jQuery('.dhx_cal_data').trigger(e); });

jQuery('.counseling_slot').live('dblclick', function(){ jQuery('.dhx_cal_data').dblclick(); });
I also tried altering the scheduler library directly, by adding this to scheduler._on_dbl_click(). Original function code:

scheduler._on_dbl_click=function(e,src){ src = src||(e.target||e.srcElement); if (this.config.readonly) return; var name = src.className.split(" ")[0]; switch(name){ case "dhx_scale_holder": case "dhx_scale_holder_now": case 'dhx_month_body':
I added a few lines to treat double-clicking on that event type identically to clicking on the general function body:

[code]scheduler._on_dbl_click=function(e,src){
src = src||(e.target||e.srcElement);
if (this.config.readonly) return;
var name = src.className.split(" “)[0];
if(src.parentNode.className.split(” ")[1]==‘type_open_counseling_slot’) {
name = ‘type_open_counseling_slot’;
}

switch(name){
	case "dhx_scale_holder":
	case "dhx_scale_holder_now":
	case 'type_open_counseling_slot':
	case 'dhx_month_body':

[/code]
Unfortunately that just produced unhelpful errors like “H is undefined” that lead me to believe that it’s not the right solution.

Is the functionality I want possible to implement without major changes to the scheduler library? Is it possible to click a link and create an event at the equivalent start time and column?
Thanks in advance for your help.

Hello,

You can try following:

scheduler.attachEvent("onDblClick", function (event_id, native_event_object){ var ev = scheduler.getEvent(event_id); scheduler.addEventNow(ev.start_date, ev.end_date); // lightbox form will be displayed return false; // blocking default click action });
Though note that such handler will create lightbox for all events and block all action. Most likely you need to place some kind of condition:

scheduler.attachEvent("onDblClick", function (event_id, native_event_object){ var ev = scheduler.getEvent(event_id); if(ev.type == "filler"){ scheduler.addEventNow(ev.start_date, ev.end_date); // lightbox form will be displayed return false; // blocking default click action } return true; // by default });

Best regards,
Ilya