Skip to content

EspoCRM – Open Source CRM Application

datepicker change month event

Yuri Kuznetsov7d37a6ab5540
diff --git a/client/src/ui/datepicker.js b/client/src/ui/datepicker.js
index 23a1ae67f5..8e464cbb2c 100644
--- a/client/src/ui/datepicker.js
+++ b/client/src/ui/datepicker.js
@@ -67,6 +67,7 @@ class Datepicker {
* hasMonth?: function(string): boolean,
* hasYear?: function(string): boolean,
* onChangeDate?: function(),
+ * onChangeMonth?: function(string),
* }} options
*/
constructor(element, options) {
@@ -185,6 +186,13 @@ class Datepicker {
if (options.onChangeDate) {
options.onChangeDate();
}
+ })
+ .on('changeMonth', (/** {date: Date} */event) => {
+ if (options.onChangeMonth) {
+ const dateString = moment(event.date).startOf('month').format(options.format);
+
+ options.onChangeMonth(dateString);
+ }
});
if (element.classList.contains('input-group') && !(element instanceof HTMLInputElement)) {