Javascript NoGray日历添加截止日期的天数,如果该日期被阻止,请检查选定阻止日期后的可用性
我以前在这个地方问过一个类似的问题,关于检查单一日历的问题。现在,对于第二个日历,我试图让它在我的计算中检查上一个日期,添加一个天数,我选择为7天,然后检查该日期是否可用,如果不执行与第一个日历相同的操作,方法是检查日期后的每一天,直到该日期可用,然后选择该日期。因此,为了明确起见,从第一个日历选择日期算起的天数并不是完全固定的,只有当它选择的日期可用时,如果不可用,它才会移动到下一个可用日期 这是我目前正在尝试的代码。这是我试图解决的第二个加载,日历2 my_cal2的加载:Javascript NoGray日历添加截止日期的天数,如果该日期被阻止,请检查选定阻止日期后的可用性,javascript,php,jquery,date,calendar,Javascript,Php,Jquery,Date,Calendar,我以前在这个地方问过一个类似的问题,关于检查单一日历的问题。现在,对于第二个日历,我试图让它在我的计算中检查上一个日期,添加一个天数,我选择为7天,然后检查该日期是否可用,如果不执行与第一个日历相同的操作,方法是检查日期后的每一天,直到该日期可用,然后选择该日期。因此,为了明确起见,从第一个日历选择日期算起的天数并不是完全固定的,只有当它选择的日期可用时,如果不可用,它才会移动到下一个可用日期 这是我目前正在尝试的代码。这是我试图解决的第二个加载,日历2 my_cal2的加载: my_c
my_cal1 = new ng.Calendar({
input: {date:'date1', month:'month1', year:'year1'},
selected_date:new Date(),
display_date:new Date(),
dates_off:[{date:1, month:0},{date:25, month:11},{date:24, month:6, year:2014},{date:27, month:6, year:2014},{date:28, month:6, year:2014},{date:29, month:6, year:2014},{date:30, month:6, year:2014},{date:31, month:6, year:2014},{date:8, month:7, year:2014},{date:9, month:7, year:2014}],
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);
}
}
});
my_cal2 = new ng.Calendar({
input: {date:'date1', month:'month1', year:'year1'},
selected_date:new Date(),
display_date:new Date(),
dates_off:[{date:1, month:0},{date:25, month:11},{date:24, month:6, year:2014},{date:27, month:6, year:2014},{date:28, month:6, year:2014},{date:29, month:6, year:2014},{date:30, month:6, year:2014},{date:31, month:6, year:2014},{date:8, month:7, year:2014},{date:9, month:7, year:2014}],
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();
console.log(this.is_selectable(st_dt)[0]);
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()))
{
var stt_dt = this.select_date(st_dt.from_string('today + 7')).clone();
console.log(this.is_selectable(stt_dt)[0]);
while(!this.is_selectable(stt_dt)[0])
{
stt_dt = stt_dt.from_string('today + 1');
}
if (!ng.defined(this.get_selected_date(stt_dt)))
{
this.select_date(stt_dt);
}
}
this.set_start_date(stt_dt);
}
}
});
任何帮助都将不胜感激。提前谢谢
更新:
我尝试使用我的\u cal2。获取所选的\u日期():
这可以工作,但现在之前的所有日期都不可用,即使它们没有被阻止,而且当您使用get_day_查看两个日期之间的差异时,它也不能正常工作
仍然需要帮助。谢谢。是的,我找到了答案:
onLoad: function()
{
var theDate = my_cal1.get_start_date().clone();
theDate = theDate.from_string('today + 7');
var st_dt = theDate.clone();
console.log(this.is_selectable(st_dt)[0]);
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);
}
var origDate = my_cal1.get_start_date();
this.set_start_date(origDate);
this.set_selected_date(st_dt);
},
感谢所有试图解决这个问题的人
onLoad: function()
{
var theDate = my_cal1.get_start_date().clone();
theDate = theDate.from_string('today + 7');
var st_dt = theDate.clone();
console.log(this.is_selectable(st_dt)[0]);
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);
}
var origDate = my_cal1.get_start_date();
this.set_start_date(origDate);
this.set_selected_date(st_dt);
},