[英]DateRangePicker not firing “Apply” event after the first Apply
I'm trying to use 7 Daterangepickers for planning 7 daterange one after the others.我正在尝试使用 7 个 Daterangepickers 一个接一个地计划 7 个 daterange。 The idea is the following: when a daterange is selected clicking on "Apply", all the following daterange auto-update choosing following dateranges.
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???
我是否以错误的方式更新 Startdate 和 EndDate ???
And the answer was: YES, I was updating Startdate and EndDate in the wrong way.答案是:是的,我以错误的方式更新 Startdate 和 EndDate。 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'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.