Javascript NoGray日历无法使用带有onDateClick或onSelect的this.is_selectable()函数阻止日期 [英] Javascript NoGray Calendar not working with blocked dates using this.is_selectable() with onDateClick or onSelect

查看:142
本文介绍了Javascript NoGray日历无法使用带有onDateClick或onSelect的this.is_selectable()函数阻止日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用onDateClick选择与this.is_selectable()有NoGray日历的问题。您可以在 http://www.nogray.com/calendar.php 上找到日历。我遇到的问题是,最初,当我重新选择日历中已经选择的日期,它取消选择,但使用这个固定的:

I am having a problem with the NoGray Calendar using the onDateClick selection with this.is_selectable(). The calendar can be found at http://www.nogray.com/calendar.php. The problem I am having is that originally, when I reselected a date in the calendar that had already been selected, it unselected it, but using this fixed that:

            onDateClick: function(dt)
            {
                this.select_date(dt);
            }

我得到这个修复从答案发布在 Javascript Calendar再次选择日期而不是重新选择日期时取消选择日期它,除非现在,如果日期已被阻止,它不会在日历中选择它,但技术上它选择选择它,因为它仍然显示在以下脚本,这只是意味着,如果日期是

I got this fix from the answer to this was posted at Javascript Calendar deselecting date when date is selected again instead of reselecting it, except now, if the date has been blocked, it doesn't select it in the calendar but technically it does select select it as it still shows in the following script which is only meant to pass if the date is selectable and not blocked.

我的代码如下:

<select id="date1"></select>
<select id="month1"></select>
<select id="year1"></select>

<select id="date2"></select>
<select id="month2"></select>
<select id="year2"></select>


<script src="PATH/TO/ng_all.js" type="text/javascript"></script>
<script src="PATH/TO/components/calendar.js" type="text/javascript"></script>
<script type="text/javascript">
var my_cal1, my_cal2;
ng.ready(function(){
    my_cal1 = new ng.Calendar({
        input: {date:'date1', month:'month1', year:'year1'},
                        selected_date:new Date(),display_date:new Date(),
                        dates_off:[{date:21, month:7, year:2014}],
        events:
        {
            onDateClick: function(dt)
            {
                if (this.is_selectable(dt)){
                    this.select_date(dt);
                    var dt2 = my_cal2.get_selected_date();
                    if ((ng.defined(dt2)) && (dt2 != ""))
                    {
                        theoutputtext=dt2.get_day_since(dt);
                    }
                }
            }
        }
    });

    my_cal2 = new ng.Calendar({
        input: {date:'date2', month:'month2', year:'year2'},
                    dates_off:[{date:21, month:7, year:2014}],
        events:
        {
            onDateClick: function(dt)
            {
                if (this.is_selectable(dt)){
                    this.select_date(dt);
                    var dt1 = my_cal1.get_selected_date();
                    if ((ng.defined(dt1)) && (dt1 != ""))
                    {
                        theoutputtext=dt.get_day_since(dt1);
                    }
                }
            }
        }
    });
});
</script>

this.is_selectable()if语句有些问题,

There is something wrong with the "this.is_selectable()" if statement as it keeps passing it as true whether the date is blocked or not.

我用onSelect和onDateClick尝试了这个方法,但它依然不是工作

I have tried this with "onSelect", with "onDateClick" and on its own, but that still doesn't seem to work either.

如何修正这个问题,以便当日期被阻止时,它不会将日期传递到日历,而theoutputtext如果用户选择了一个已经选择的日期,并且没有取消选择它仍然工作,因为它没有this.select_date(dt)部分?

How can this be fixed to work so that when the date is blocked, it doesn't pass the date through to the calendar and the "theoutputtext" as well as still working if a user selects a date that is already selected and does not unselect it as it does without the "this.select_date(dt)" part?

谢谢

推荐答案

is_selectable方法返回一个数组,第一个索引为true或false,第二个为原因。您可以在这里找到文档 http://www.nogray.com/api/calendar/is_selectable .php

the is_selectable method returns an array with the first index is as true or false and the second is the reason. You can find the docs here http://www.nogray.com/api/calendar/is_selectable.php

在您的代码中,您可以更改 if(this.is_selectable(dt)){ if(this.is_selectable(dt)[0]){

In your code, you can change the if (this.is_selectable(dt)){ to if (this.is_selectable(dt)[0]){

这篇关于Javascript NoGray日历无法使用带有onDateClick或onSelect的this.is_selectable()函数阻止日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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