如果今天被阻止,Javascript NoGray Calendar会在选择阻止日期后找到下一个可用日期

时间:2014-07-22 22:22:39

标签: javascript php jquery calendar

我正在使用NoGray Calendar并拥有以下代码:

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},
    events: {
        onDateClick: function(dt) {
            this.select_date(dt);
        }
    }

但是当它与我所在的那天相同时,它显示为空白。

如何才能显示并查看阻止日期之后的下一个可用日期?

可以在http://www.nogray.com/example.php?ID=260

找到示例日历

我要设置的区域是下一个可用日期的start_datedisplay_date,因此,如果我在接下来的3天休息日,它会将日期显示为下一个可用日期在它开始的那3天之后的日期。

这可以通过NoGray软件中的功能完成,还是我需要使用PHP脚本搜索下一个可用日期并输出所需日期?

1 个答案:

答案 0 :(得分:1)

您可以使用is_selectable http://www.nogray.com/api/calendar/is_selectable.php方法检查日期是否可选。 is_selectable返回一个数组[true | false,' reason']。以下是一个简单的例子

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);
        }
    }
});