我在使用 JQUI 日期选择器时遇到了问题,其中我有一个 from 和 to 文本字段。选择一个起始日期,使用该onClose
功能自动选择下一个字段。
当试图从文本字段中的下拉框中更改月份或年份时,日期选择器弹出窗口会被重置,用户必须重新选择月份或年份。这似乎只发生在to字段上。
我在代码中做错了什么导致这种行为吗?我在 Windows 上的 Chrome 和 Firefox 中注意到了这一点。
代码
$('#sfd_start').datepicker({
inline: true,
selectOtherMonths: true,
changeMonth: true,
changeYear: true,
minDate: 0,
maxDate: "+2y",
dateFormat: "yy-mm-dd",
onClose: function (selectedDate) {
$('#sfd_end').datepicker('option', 'minDate', selectedDate);
$('#sfd_end').focus();
}
});
$('#sfd_end').datepicker({
inline: true,
selectOtherMonths: true,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
maxDate: "+2y"
});
编辑:如果日期选择器在选择起始日期后没有自动打开,这似乎没有问题,如果这有助于缩小范围。