Skip to main content

Event Handling

Attaching event listeners#

You can attach event listeners with the method of the events module:"change",function(date, oldDate, byClick){    console.log("Change selection from "+oldDate+" to "+date);    console.log(click);});

For example, Calendar can be attached to an input that will display the date selected in Calendar:

<input type="text" id="date" />
var calendar = new dhx.Calendar("calendar_container");"change",(date)=>{     document.getElementById("date").value = date.getFullYear() +        "-" + (date.getMonth() + 1) + "-" +date.getDate();});

Several handlers can be attached to one event, and all of them will be executed.


The names of events are case-insensitive.

Related sample: Calendar. Events

Detaching event listeners#

To detach an event listener, use"change",function(date, oldDate, byClick){    console.log("Change selection from "+oldDate+" to "+date);    console.log(click);});"change");

Calling events#

To call an event, use"name",args);// where args is an array of arguments

The list of events#

You can find the full list of events in the Calendar API.