双击从日期更改到日期也在日期范围日期选择器中

Double Click on from date change the to date also in Date range datepicker

当我在日期范围日期选择器中双击起始日期时,截止日期也会发生变化。

$(function() {
    $( "#from" ).datepicker({
        onClose: function( selectedDate ) {
            $( "#to" ).datepicker( "option", "minDate", selectedDate );
        }
    });
    $( "#to" ).datepicker({
        onClose: function( selectedDate ) {
            $( "#from" ).datepicker( "option", "maxDate", selectedDate );
        }
    });
});

这是我的 jsfiddle: jsfiddle

这是一个错误:https://bugs.jqueryui.com/ticket/8907#no1

What happens is that calling a method on datepicker 2 while datepicker 1 is open causes datepicker 2 to be rendered in place of datepicker 1. You can see this happening by selecting a date in a different month for datepicker 2, then selecting a date in datepicker 1; you'll see the month switch as the datepicker is closing.

但是如果你使用超时,一切都正确!在 jsfiddle 上查看。

setTimeout(function(){ $( "#to" ).datepicker( "option", "minDate", selectedDate );}, 100);

https://jsfiddle.net/7x0pwtxf/