如果今天被阻止,Javascript NoGray Calendar 在选择的阻止日期之后查找下一个可用日期 [英] Javascript NoGray Calendar find next available date after chosen blocked dates if today is blocked

查看:15
本文介绍了如果今天被阻止,Javascript NoGray Calendar 在选择的阻止日期之后查找下一个可用日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

But when it is the same day as the day I am on, it shows as blank.

我怎样才能让它显示并查找下一个可用日期从被阻止的日期之后开始?

How can I make it so it displays and looks for the next available date to start from after the blocked date please?

可以在 http://www.nogray.com/找到示例日历example.php?ID=260

我要设置的区域是 start_datedisplay_date 到下一个可用日期,所以如果我有接下来 3 天的休息日,它会显示开始的 3 天之后的下一个可用日期.

The areas that I am trying to set are the start_date and display_date to the next available date so if I had the next 3 days as days off, it would show the date as the next available date after those 3 days when it starts.

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

Can this be done with the functions within the NoGray software or do I require to use a PHP script to search for the next available date and out put the required date?

推荐答案

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

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

这篇关于如果今天被阻止,Javascript NoGray Calendar 在选择的阻止日期之后查找下一个可用日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆