I'm trying to use 7 Daterangepickers for planning 7 daterange one after the others. The idea is the following: when a daterange is selected clicking on "Apply", all the following daterange auto-update choosing following dateranges.
$('.sprintdate').on('apply.daterangepicker', function (ev, picker) {
var sprintid = $(this).data("sprintid");
var start = new Date(picker.startDate.format('YYYY-MM-DD'));
var end = new Date(picker.endDate.format('YYYY-MM-DD'));
var i;
var k = 0;
for (i = sprintid+1; i <= 6; i++) {
var startNew = new Date();
var endNew = new Date();
startNew.setDate(end.getDate() + 1+k*14);
endNew.setDate(end.getDate() + (k+1)*14);
k++;
$("#sprint"+i).daterangepicker({
startDate: moment(start New).format('MM/DD/YYYY'),
endDate: moment(endNew).format('MM/DD/YYYY'),
locale: {
format: "DD/MM/YYYY",
"firstDay": 1
}
}).effect("highlight", {color: '#58D68D'}, 1000);
}
});
The previous code works, but only for the first "Apply"; after that, the following dataranges will not auto-update. Am I updating Startdate and EndDate in a wrong way???
And the answer was: YES, I was updating Startdate and EndDate in the wrong way. Here it is the correct version to do it!
$("#sprint"+i).data('daterangepicker').setStartDate(moment(startNew).format('DD/MM/YYYY'));
$("#sprint"+i).data('daterangepicker').setEndDate(moment(endNew).format('DD/MM/YYYY'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.