bootstrap-datepicker icon indicating copy to clipboard operation
bootstrap-datepicker copied to clipboard

Reset daterange selection

Open reignmaker opened this issue 10 years ago • 2 comments

Hello. How can i reset/update daterange? I'm reseting my form with form.reset() and i want my selected date range to reset too. $.datepicker('updateDates'), $.datepicker('updateRanges'), $.datepicker('update', '') and $.datepicker('clearDates') give no result.

reignmaker avatar May 24 '15 14:05 reignmaker

Actually when doing a date range, the container you instantiate will have a DateRangePicker class which does not have the regular methods. In order to use methods on a date range, you should loop on the inputs to access the Datepicker. Ie:

$('.input-daterange input').each(function (){
  $(this).datepicker("clearDates");
});

The docs is actually not really clear about this fact, I guess that for 1.5 we can add a note to be clear about this. I guess that for 1.6 it can be planed to add some methods for the DateRangePicker class in order to shortcuts Datepicker methods.

Azaret avatar Jun 18 '15 18:06 Azaret

@Azaret it reset daterange but the first datepicker is stuck on the old selected month not return to current month. Does exists fix for this behavior ?

zoaina avatar Jul 05 '22 06:07 zoaina