Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
禁用Zebra Date Picker jQuery插件中日期之前的所有日期_Jquery_Datepicker - Fatal编程技术网

禁用Zebra Date Picker jQuery插件中日期之前的所有日期

禁用Zebra Date Picker jQuery插件中日期之前的所有日期,jquery,datepicker,Jquery,Datepicker,我正在使用一个名为斑马日期选择器的jQuery日期选择器插件: mixed An array of disabled dates in the following format: ‘day month year weekday’ where “weekday” is optional and can be 0-6 (Saturday to Sunday); The syntax is similar to cron’s syntax: the values are separated by

我正在使用一个名为斑马日期选择器的jQuery日期选择器插件:

mixed   
An array of disabled dates in the following format: ‘day month year weekday’ where “weekday” is optional and can be 0-6 (Saturday to Sunday); The syntax is similar to cron’s syntax: the values are separated by spaces and may contain * (asterisk) – (dash) and , (comma) delimiters: 
斑马日期选择器:
GitHub

我在一个项目管理应用程序上使用它,该应用程序在模式DIV中打开项目任务记录,并设置此日期选择器以选择任务到期日期

该插件可以选择禁用所选日期。下面显示了有关设置日期的文档,这些日期可以
禁用
启用

我的目标是禁用
任务创建日期之前的所有日期
,以便
到期日期
不能设置为任务记录创建日期之前的日期

这段代码是如何在输入字段上设置日期选择器并传入选项

$('#datepicker').Zebra_DatePicker({
    disabled_dates: 'ARRAY of DISABLED DATES',
    enabled_dates: 'ARRAY of ENABLED DATES',
});

下面是关于禁用日期的文档…

禁用日期

mixed   
An array of disabled dates in the following format: ‘day month year weekday’ where “weekday” is optional and can be 0-6 (Saturday to Sunday); The syntax is similar to cron’s syntax: the values are separated by spaces and may contain * (asterisk) – (dash) and , (comma) delimiters: 
[2012年1月1日]将于2012年1月1日失效

['*1 2012']将禁用2012年1月的所有工作日

[1-10 1 2012']将在2012年1月1日至10日禁用

[1,10 1 2012']将在2012年1月1日和10日禁用

['1-10,20,22,24 1-3*']将禁用1到10,加上每年1月22日和24日到3月

['***0,6']将禁用所有周六和周日

[01 07 2012'、'02 07 2012'、*08 2012']将禁用2012年7月1日和2日以及2012年8月的所有时间

默认值为FALSE,没有禁用的日期

禁用所有日期而不指定至少一个已启用日期将使脚本进入无限循环,搜索已启用日期 要显示的日期


启用\u日期

混合
已启用日期的数组,其格式与 “禁用日期”属性。与 “disabled_dates”属性,方法是首先设置“disabled_dates” 属性设置为类似“[***]”(这将禁用所有内容) 将“enabled_dates”属性设置为,比如,“[**0,6]”设置为 只启用周末。 默认值为FALSE



假设我的任务创建日期是
2015-04-21
,有人能告诉我禁用此日期之前所有日期的好方法吗?

我得到了一个解决方案。事实证明,如果一个日期上有一个名为
dp_disabled
的CSS类,那么它将禁用这些日期上的点击事件

因此,使用Callback
onChange()
函数,我可以将这个CSS类应用于指定日期之前的所有日期!工作很好

onChange: function(view, elements) {

    // on the "days" view...
    if (view == 'days') {

      // iterate through the active elements in the view
      elements.each(function() {


        //if Date is before the Task created date, then add a CSS Class.
        var taskCreatedDate = new Date('2015-04-23');
        var currentDay = new Date($(this).data('date'));

        if (currentDay < taskCreatedDate){

          $(this).addClass('dp_disabled');

        }
      });

    }
},
onChange:函数(视图、元素){
//在“天”视图中。。。
如果(视图=‘天’){
//遍历视图中的活动元素
元素。每个(函数(){
//如果日期早于任务创建日期,则添加CSS类。
var taskCreatedDate=新日期('2015-04-23');
var currentDay=新日期($(this).data('Date');
如果(当前日期<任务创建日期){
$(this.addClass('dp_disabled');
}
});
}
},

为什么不使用
方向
-选项? 您可以为此指定一个日期:

$('input').Zebra_DatePicker({
    direction: ['2015-04-21', false]
});
从文档中:

  • 可以在将来选择日期,从特定日期开始