【问题标题】:Months are moving automatically after selecting 2 Dates in multiDate Picker在多日期选择器中选择 2 个日期后,月份会自动移动
【发布时间】:2019-09-27 05:01:08
【问题描述】:

我正在使用 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 文件是什么问题?

【问题讨论】:

  • 这是一个已知问题:见here;特别是。检查this 评论以获取解决方法。
  • 感谢您的评论。它对我有用@Rakesh G R

标签: javascript jquery calendar jquery-multidatespicker


【解决方案1】:

这对我有用。

<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-26
    • 2016-08-24
    • 2017-05-01
    • 1970-01-01
    • 2012-04-29
    • 2022-07-23
    • 1970-01-01
    • 2012-01-08
    相关资源
    最近更新 更多