我在使用JQUI数据报警器时遇到了一个问题,在这里我有一个from和to文本字段。选择from日期,auto使用onClose函数选择下一个字段。
当尝试将中的下拉框中的月份或年份更改为文本字段时,数据报警器弹出会被重置,用户必须重新选择月份或年份。这似乎只发生在 to 字段中。
我是不是在代码中做错了什么导致这种行为?我在Windows上的Chrome和Firefox中注意到了这一点。
JS小提琴演示
码
$('#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"
});编辑:如果数据报警器是而不是自动打开,在选择from日期后打开,这似乎没有什么问题,如果这有助于缩小范围。
发布于 2013-08-19 13:59:10
似乎是时间问题。将onClose函数更改为:
onClose: function (selectedDate) {
$('#sfd_end').datepicker('option', 'minDate', selectedDate);
setTimeout(function () {
$('#sfd_end').focus();
}, 100);
}jsFiddle实例
https://stackoverflow.com/questions/18315410
复制相似问题