bootstrap-datepicker beforeShowDay无法正常工作

时间:2016-10-07 13:45:33

标签: javascript jquery twitter-bootstrap-3 datepicker bootstrap-datepicker

我有这个html元素,它有datepicker(bootstrap-datepicker)(没有beforeShowDays就可以正常工作)

<input class="form-control text-center"  placeholder="Day" onChange="nice_ajax_3(<?=$_us_id_responsible?>,this.value.toString())"  id="_taho_day" name="_taho_day" ">

但是,当我尝试突出某些特定日期(假期等)它没有用时,我已经尝试了所有日期格式(即&#39; yyyy-mm-dd&#39;, &#39; yyyy / mm / ddd&#39;,&#39; mm-dd-yyyy&#39;等等)

这里是datepicker的代码(各种答案的一些概念混合在一起):

$(document).ready(function () {
  super_datepicker();
});

var unavailableDates = ["2016-10-10","2016-10-11"];

function unavailable(date) {
    dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" +date.getFullYear();
    if ($.inArray(dmy, unavailableDates) < 0) {
        return [true,"highlighted day","highlighted day"];
    } else {
        return [true,"highlighted day","highlighted day"];
    }
}

function super_datepicker(){
  // var date1 = new Date(2016, 9, 6);
  // var date2 = new Date(2016, 9, 17);

  // var date1 = "2016-10-12";
  // var date2 = "2016-10-10";

  $("#_taho_day").datepicker({
    multidate: true,
    todayHighlight: true,
    daysOfWeekHighlighted: "0,6",

    beforeShowDay: unavailable
  });
}

这里是周末工作的图像和datepicker本身(使周末变为蓝色的类是#34;突出显示日期和#34;这就是我尝试应用它的原因)

enter image description here

0 个答案:

没有答案