Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by markus on Jan 19, 2010 04:35
open dhtmlx forum
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
Answer posted by Stanislav (support) on Jan 19, 2010 05:31
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;
   ...
})
Answer posted by markus on Jan 20, 2010 06:22

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".

Answer posted by Alex (support) on Jan 20, 2010 08:29

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)*24*60)*60000;
})