简体   繁体   中英

onSelect event datepicker triggers change of minTime value in timepicker

When "today" is selected in datepicker, the minTime of timepicker is = current time, and if the select date is not today, the minTime of timepicker is = "12:00am" . But the minTime value (below) is never being triggered (I guess) when I tried to select different date. The console.log() shows the if statement is working fine thou.

var selection = jQuery("input#ezfc_element-15-child.ezfc-element-timepicker").data("settings");
var today = localdate.toLocaleDateString("en-US");
setTimeout(function(){
    jQuery( ".ezfc-element-datepicker" ).datepicker({
        minDate: new Date(today),
        defaultDate: new Date(today),
        onSelect: function(dateText) {
            var ds_milliseconds = Date.parse(dateText);
            var t_milliseconds = Date.parse(today);
            if (t_milliseconds == ds_milliseconds) {
                selection['minTime'] = minTime;
                console.log ("minTime");
            } else { 
                selection['minTime'] = "12:00am" ;
                console.log("12:00am");
            }
        }
     });

 }, 3000);

Have you tried opening your browser console, selection is not a valid usage, replace your if else section with below code

if (t_milliseconds == ds_milliseconds) {
    $(this).datepicker('option', 'minTime', minTime);
    console.log ("minTime");
} else { 
    $(this).datepicker('option', 'minTime', "12:00am");
    console.log("12:00am");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM