Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update the selected dates of date range picker for Twitter Bootstrap

I'm using the date range picker for Twitter Bootstrap, by Dan Grossman.

When initialized, it's possible to set pre-defined values like startDate and endDate. Is it possible to update the values manually later on in a similar way?

What I want to do is to "load" the date range picker with filters I have saved, which includes a start and end date (not by defining pre-defined ranges). Just updating the field of the date range picker through jQuery won't update the actual selection of the calendar.

I guess I should do something like this when initializing the date range picker:

var reportrange = $('#reportrange').daterangepicker(),
DateRangePicker = reportrange.data('daterangepicker');

But then, how to use DateRangePicker to update the date range picker and calendar with new selected dates manually?

like image 697
Gustav Avatar asked Sep 23 '13 09:09

Gustav


1 Answers

The latest version of this component provides methods for updating the start/end date:

$("#reportrange").data('daterangepicker').setStartDate(startDate);
$("#reportrange").data('daterangepicker').setEndDate(endDate);

You don't have to call the update methods yourself as these will handle all that.

like image 56
Dan Grossman Avatar answered Sep 17 '22 15:09

Dan Grossman