在multiDate Picker中选择2个日期后,月份会自动移动

时间:2019-05-09 11:08:10

标签: javascript jquery calendar jquery-multidatespicker

我正在使用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/

我想选择10月到当前日期之间的日期,我可以选择日期数。但是,当我选择上个月的2个日期(如2jan和3 jan之后)时,它将自动移至4月和5月。我想留在那个月,直到我不动箭头。

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

1 个答案:

答案 0 :(得分: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>