Javascript jquery Datepicker onClose上的SetDate不更改值

Javascript jquery Datepicker onClose上的SetDate不更改值,javascript,jquery,html,datepicker,jquery-ui-datepicker,Javascript,Jquery,Html,Datepicker,Jquery Ui Datepicker,我有一张桌子,每行有一个日期选择器。日期选择器只选择月份,在结束时,我设置了月份的第一天,除非这一天在minDate之前,所以我想在那里设置minDate SetDate函数不起作用。我的日志告诉我properDate设置正确,但当我在setDate中传递它时,结果不会改变,不知何故,它会叠加到每月的第一天。我错过了什么 function initDatepickerSchedule(){ $(".datepickerSchedule").each(function

我有一张桌子,每行有一个日期选择器。日期选择器只选择月份,在结束时,我设置了月份的第一天,除非这一天在minDate之前,所以我想在那里设置minDate

SetDate函数不起作用。我的日志告诉我properDate设置正确,但当我在setDate中传递它时,结果不会改变,不知何故,它会叠加到每月的第一天。我错过了什么

    function initDatepickerSchedule(){  

        $(".datepickerSchedule").each(function(){

            $(this).datepicker({
                showOn: "both",
                changeMonth: true,
                changeYear: true,
                dateFormat: "yy-mm-dd",
                minDate: scheduleTaskMinDate(),
                maxDate: scheduleTaskMaxDate($(this).closest("tr").find(".ScheduledTaskQtyInput").val(),$(this).closest("tr").find(".ScheduledTaskCompletedQtyInput").val()),
                showButtonPanel: true,  
                onClose: function(dateText, inst) { 
                    function isDonePressed(){
                       return $('#ui-datepicker-div').html().indexOf('ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all ui-state-hover') > -1;
                    }

                    if (isDonePressed()){
                        var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                        var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                        var properDate=new Date(year, month, 1);
                        var minDate=$(this).datepicker("option","minDate");                  
                        console.log(properDate);// 2019-12-1
                        console.log(minDate);//2019-12-2
                        console.log(properDate<minDate);// true
                        if(properDate<minDate){
                            properDate=minDate;
                        }
                        console.log("before set");
                        console.log(properDate===minDate);//true
                        console.log(properDate);//2019-12-2

                        $(this).datepicker("setDate",properDate);
                        console.log($(this).datepicker("getDate"));//2019-12-1
                        var coNo=$(this).closest("tr").find(".changeOrderNoInput").val();
                        $(this).closest("tr").find(".ScheduledTaskVersion").val(studyTaskScheduleVersion($(this).datepicker("getDate"),coNo));
                        $("#SubmitScheduleDistButton").prop('disabled', true).prop('title',"Validate without Errors to Unlock");
                    }
                }               
            }).focus(function(){
                $(".ui-datepicker-calendar").hide();
                $(this).attr("autocomplete","off");
            });
        });
    }
函数initDatepickerSchedule(){
$(“.datepickerSchedule”)。每个(函数(){
$(此).datepicker({
showOn:“两者”,
变化月:对,
变化年:是的,
日期格式:“年月日”,
minDate:scheduleTaskMinDate(),
maxDate:scheduleTaskMaxDate($(this).closest(“tr”).find(“.ScheduledTaskKQtyInput”).val(),$(this).closest(“tr”).find(“.ScheduledTaskKCompletedQtyInput”).val()),
showButtonPanel:是的,
onClose:函数(dateText,inst){
函数isDonePressed(){
返回$('#ui datepicker div').html().indexOf('ui-datepicker-close ui state default ui priority priority primary ui corner all ui state hover')>-1;
}
如果(isDonePressed()){
var month=$(“#ui datepicker div.ui datepicker month:selected”).val();
var year=$(“#ui日期选择器div.ui日期选择器year:selected”).val();
var properDate=新日期(年、月、1);
var minDate=$(this).datepicker(“选项”,“minDate”);
console.log(properDate);//2019-12-1
console.log(minDate);/2019-12-2

console.log(properDate似乎max Date确实相关。在这种特定情况下,我应该在maxDate的同一个月内有一个日期,但出于某种原因(我不记得并检查了程序其他部分可能产生的影响,但我找不到任何问题),我返回了该月的第一个日期

所以这并没有在datepicker上显示,因为日历是隐藏的,所以我不知道。 这就是它重写set函数的方式,导致maxDate