uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.65k stars 6.08k forks source link

Reset daterange selection #1412

Open reignmaker opened 9 years ago

reignmaker commented 9 years ago

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.

Azaret commented 9 years ago

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.

zoaina commented 2 years ago

@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 ?