get clicked date/time

Hi,



I’m using the dhtmlx scheduler as readonly calendar. Now i need to get the date/time on which the user clicked for an external input field.

I tried



scheduler.attachEvent(“onClick”, function (event_id, native_event_object){

alert(‘Juhu’);

});



but this is just working if the user clicks on an event, I also need it if he clicks on an empty space in the scheduler.



Thanks in advance,



Markus

You can assign event handler directly

//need to be called after scheduler.init
dhtmlxEvent(scheduler._els[“dhx_cal_data”][0],“click”,function(e){
e = e||event;

})


Thanks, this works. It is called if I click on the calendar.



But now I have no idea which structure the object “e” has. Where can i find a documentation?



I would need the date/time from “e”.


In this case e is native event object. So this object doesn’t have any data properties.


You can try to use the following:


dhtmlxEvent(scheduler._els[“dhx_cal_data”][0],“click”,function(e){
e = e||event;

var pos = scheduler._mouse_coords(e);


var timestamp = scheduler._min_date.valueOf()+(pos.y*scheduler.config.time_step+(scheduler._table_view?0:pos.x)2460)*60000;
})






Hi
I would also like to get the date the user clicked in whichever box in the scheduler.

this code throws an error: Uncaught SyntaxError: Unexpected number

this is strange to me because I do not understand all of what is going on here. But I got this to work by removing the 2460 number

dhtmlxEvent(scheduler._els["dhx_cal_data"][0],"click",function(e){
	var pos=scheduler._mouse_coords(e);
	var start=scheduler._min_date.valueOf()+(pos.y*scheduler.config.time_step+(scheduler._table_view?0:pos.x))*60000;
	console.log(new Date(start));
return false;
});