Get the last cleared/unselected date

43 views
Skip to first unread message

Nipuna Dodantenna

unread,
Aug 17, 2021, 7:31:26 AM8/17/21
to bootstrap-datepicker
TL;DR Is there a way to get the last cleared date?

I want to fire a callback function when the user clear/unselect a date and I want to pass the unselected date to the function. How can I do this?

Following is the initialization.

$('#bd-picker').datepicker({
   multidate: true,
   weekStart: 1,
   maxViewMode: 2,
   clearBtn: false,
   format:'yyyy-mm-dd',
   daysOfWeekHighlighted: "0,6",
   autoclose: false,
   todayHighlight: true,
});


I tried the following with no luck. It doesn't even fire the callback.

$('#bd-picker').datepicker().on('clearDate', function (event) {
   const cleared = $('#bd-picker').datepicker('getDate')
   console.log(event.date)
   console.log(cleared)
});
Reply all
Reply to author
Forward
0 new messages