-1

我正在使用 jQuery 的多日期选择器日历。它工作正常,但在选择前几个月的两个日期后,它会自动移动到当前月份视图。

我在下面给出了我用于我的页面的代码。

$(document).ready(function() {
  $('#datePick').multiDatesPicker({
    numberOfMonths: 2,
    minDate: new Date(2018, 9, 1),
    maxDate: new Date()
  });
});
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.js"></script>

<input id="datePick" type="text" />

见小提琴----> http://jsfiddle.net/jdfou32n/2/

我想选择从十月到当前日期的日期,我可以选择日期数。但是,当我选择上个月的 2 个日期(例如 2 月 2 日和 1 月 3 日)之后,它会自动移动到 4 月和 5 月。我想留在那个月,直到我没有按箭头移动它。

有什么问题是我缺少一些 js 文件?

4

1 回答 1

0

这对我有用。

<script type="text/javascript">
 $(document).ready(function(){
        $('#captureDateRange').multiDatesPicker({
            numberOfMonths: 2,
            minDate : new Date(2018, 9, 1),
            maxDate : new Date()
        });

    $.datepicker._selectDateOverload = $.datepicker._selectDate;
    $.datepicker._selectDate = function (id, dateStr) {
        var target = $(id);
        var inst = this._getInst(target[0]);
        inst.inline = true;
        $.datepicker._selectDateOverload(id, dateStr);
        inst.inline = false;
        if (target[0].multiDatesPicker != null) {
            target[0].multiDatesPicker.changed = false;
        } else {
            target.multiDatesPicker.changed = false;
        }
             this._updateDatepicker(inst);

    };
});

</script>
于 2019-05-09T12:19:47.633 回答