Open peterox opened 8 years ago
I don't know why do you need to use 'defaultDate'.
It's being used internally by our widget. If you want some date/range highlighted just set range as the value of the replaced input element.
My scenario is this.
Currently without being able to set the defaultDate, when the user opens the date range picker the current day is displayed. The highlighted date range may not even be visible. This is a bad user experience.
You said 'If you want some date/range highlighted just set range as the value of the replaced input element.'. Do you mean that if I want a particular date range to be displayed then I should just set the initial date range to that value? If this is what you mean then that does not work for me as the date range is optional. Setting it to a pre-defined range would mean the user would need to click 'clear' which again is not a good user experience.
The highlighted date range may not even be visible. This is a bad user experience.
I agree. That's why I had to use defaultDate in the first place, so that the pre-defined/ previously selected range is visible when the user opens the date range picker.
Just test it work for me: Case 1:
var start_date = moment().subtract('days', 1).startOf('day').toDate();
var end_date = moment().subtract('days', 1).startOf('day').toDate();
$("#e1").daterangepicker("setRange", {start: start_date, end: end_date});
Case 2:
var startDate = "{$php.startDate}";
var startDate = "{$php.endDate}";
var start_date = moment(startDate).subtract('days', 0).startOf('day').toDate();
var end_date = moment(endDate).subtract('days', 0).startOf('day').toDate();
$("#e1").daterangepicker("setRange", {start: start_date, end: end_date});
When setting the datepickeroption 'defaultDate', the widget is being displayed with the current date instead of the 'defaultDate' .
To reproduce