Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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
Jquery 引导数据采集器datesdisabled在通过ajax提供数组时不起作用_Jquery_Ajax_Bootstrap Datepicker - Fatal编程技术网

Jquery 引导数据采集器datesdisabled在通过ajax提供数组时不起作用

Jquery 引导数据采集器datesdisabled在通过ajax提供数组时不起作用,jquery,ajax,bootstrap-datepicker,Jquery,Ajax,Bootstrap Datepicker,我通过ajax获得约会。我想在我的日期选择器上禁用这些日期。但是参数datesDisabled在我的代码中根本不起作用。它总是显示日期选择器而不禁用任何日期。下面是我的jquery代码: $(document).ready(function() { $("#people").blur(function() { var people = $("#people").val(); if(people == "" || peopl

我通过ajax获得约会。我想在我的日期选择器上禁用这些日期。但是参数datesDisabled在我的代码中根本不起作用。它总是显示日期选择器而不禁用任何日期。下面是我的jquery代码:

$(document).ready(function() {

    $("#people").blur(function() {
                var people = $("#people").val();
                if(people == "" || people == 0)
                    {
                        $("#people-error").html("Please enter number of people.");
                        return false;
                    }
                var experience_uid = $("#experience_uid").val();
                var req_url = "' . site_url() . '/wp-content/plugins/visitnorth/visitnorth.php";
                var ajax_req_for_schedule = 1;



               $.ajax({
                    async:false,
                    "type": "POST",
                    "url": req_url,
                    "data": {"people":people, "experience_uid":experience_uid, "ajax_req_for_schedule":ajax_req_for_schedule},
                    statusCode: {
                        404: function() {
                            alert("Oj, någonting gick fel. Försök igen.");
                        },
                        500: function() {
                            alert("Oops! An Internal Error has occurred.");
                        },
                    },
                    success: function (data) {
                       //output data is: ["11-08-2017, 11-05-2017, 11-03-2017"]
                       $(".datepicker").datepicker({
                            todayHighlight: true,
                            datesDisabled: data
                        });

                    }
                });

               });

            });

要禁用某些特定日期,可以覆盖将为每个日期调用的方法(
beforeShowDay
),并且可以返回css类:

beforeShowDay:函数(日期){

if(日期maxDate){
返回“无效的日期选择器”;
}
}` 
在上面的示例中,
invalid\u date\u datepicker
是一个css类,它灰显该区域


如果你也不想选择那些灰色的日期,你也可以覆盖选择的
onSelect
,并将其限制为选择那些应用了此类的日期。

我没有任何minDate或maxDate。日期动态地来自ajax。您可以在ajax结果成功时重新配置日期选择器,并可以使用
beforeShowDay
中的ajax响应禁用日期。您可以检查是否禁用日期。indexOf(date)>0,然后禁用日期,否则不禁用。如果答案对您有帮助,请您将其更新为:)。
                    if (date<minDate || date > maxDate) {
                        return 'invalid_date_datepicker';
                }
            }`