Javascript NoGray Calendar find next available date after chosen blocked dates if today is blocked

前端 未结 1 439
慢半拍i
慢半拍i 2021-01-25 05:45

I am using the NoGray Calendar and have the following code:

my_cal1 = new ng.Calendar({
    input: {date:\'date1\', month:\'month1\', year:\'year1\'         


        
1条回答
  •  孤独总比滥情好
    2021-01-25 06:15

    You can use the method is_selectable http://www.nogray.com/api/calendar/is_selectable.php to check if the dates are selectable or not. The is_selectable returns an array [true|false, 'reason']. Below is a quick example

    my_cal1 = new ng.Calendar({
        input: {date:'date1', month:'month1', year:'year1'},
        selected_date:new Date(),
        display_date:new Date(),
        dates_off:[{date:22, month:6}], // you were messing a ] here
        events: {
            onDateClick: function(dt){
                this.select_date(dt);
            },
            // code to check if the start date is selectable
            onLoad: function(){
                var st_dt = this.get_start_date().clone();
                while(!this.is_selectable(st_dt)[0]){
                    st_dt = st_dt.from_string('today + 1');
                }
                // checking if no dates are selected
                if (!ng.defined(this.get_selected_date())){
                    this.select_date(st_dt);
                }
                this.set_start_date(st_dt);
            }
        }
    });
    

    0 讨论(0)
提交回复
热议问题