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

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

问题描述

我使用 NoGray日历并具有以下代码:

  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_date display_date 到下一个可用的日期,如果我有接下来的3天作为天关闭,它将显示日期作为下一个可用



这可以通过NoGray软件中的功能来完成,或者我需要使用PHP脚本来搜索下一个可用的

您可以使用方法 is_selectable c> 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 },
},



, //代码检查开始日期是否可选
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');
}
//检查是否没有选择日期
if(!ng.defined (this.get_selected_date())){
this.select_date(st_dt);
}
this.set_start_date(st_dt);
}
}
});


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?

The example calendar can be found here at http://www.nogray.com/example.php?ID=260

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.

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?

解决方案

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日历查找在选定的阻止日期后的下一个可用日期,如果今天被阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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