Skip to content

JavaScript Calendar Events

This documentation provides examples of using events with the jSuites JavaScript Calendar plugin. Learn how to integrate interactive calendar features into your applications.

Explore the events available in the calendar plugin with examples to create dynamic and responsive features.

Eventdescription
onopenonopen(el: DOMElement) => void
Triggered when the calendar is opened.
oncloseonclose(el: DOMElement) => void
Triggered when the calendar is closed.
onchangeonchange(DOMElement element, string currentValue, string previousValue) => void
Triggered when the calendar value changes.
onupdateonupdate(DOMElement element, string value) => void
Triggered when calendar information is updated.

This example shows how to declare events like onopen, onclose, onchange, and onupdate to handle calendar interactions.

<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />

<input id='calendar' />
<div id='log'></div>

<script>
// Create a instance of the calendar
jSuites.calendar(document.getElementById('calendar'), {
    time: true,
    format: 'DD/MM/YYYY',
    placeholder: 'DD/MM/YYYY',
    readonly: false,
    // Enable events on the calendar
    onopen: function() {
        jSuites.notification({ title:'Calendar', message:'Calendar is open now!' });
    },
    onclose: function() {
        jSuites.notification({ title:'Calendar', message:'Calendar is closed now!' });
    },
    onchange: function(instance, value) {
        document.getElementById('log').innerText = 'New value is: ' + value;
    }
});
</script>
</html>

Explore additional use cases for the jSuites JavaScript Calendar plugin: