Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
jqueryui:datepicker_Jquery_Jquery Ui - Fatal编程技术网

jqueryui:datepicker

jqueryui:datepicker,jquery,jquery-ui,Jquery,Jquery Ui,我正在我的一个项目中使用jQueryUIDatePicker。我需要禁用我们的假期日期。我试着 但它们没有起作用。我怎样才能使特殊的日子不可选择 我也尝试过,snippet在appart中工作,但不在我的项目中。这是: var unavailableDates = ["31-12-2012"]; function unavailable(date) { dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFull

我正在我的一个项目中使用jQueryUIDatePicker。我需要禁用我们的假期日期。我试着

但它们没有起作用。我怎样才能使特殊的日子不可选择

我也尝试过,snippet在appart中工作,但不在我的项目中。这是:

var unavailableDates = ["31-12-2012"];

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


Drupal.behaviors.date_popup = function (context) {
  for (var id in Drupal.settings.datePopup) {
    $('#'+ id).bind('focus', Drupal.settings.datePopup[id], function(e) {
      if (!$(this).hasClass('date-popup-init')) {
        var datePopup = e.data;
        // Explicitely filter the methods we accept.
        switch (datePopup.func) {
          case 'datepicker':
            $(this)
              .datepicker({ minDate: +1, maxDate: "+3Y", beforeShow: unavailable })
              .addClass('date-popup-init')
            $(this).click(function(){
              $(this).focus();
            });
            break;

          case 'timeEntry':
            $(this)
              .timeEntry(datePopup.settings)
              .addClass('date-popup-init')
            $(this).click(function(){
              $(this).focus();
            });
            break;
        }
      }
    });
  }
};

关于您到目前为止到底尝试了什么的更多信息会很好,但无论如何:对我来说效果非常好-只是在ShowDay之前返回true/false的基本函数

我发现了这个决定。只需在所有其他函数中首先使用“beforeshow”属性

natDays = [
    [1, 1, 'New Year'],
    [1, 16, 'Martin Luther King'],
    [1, 20, 'Inauguration Day'],
    [2, 14, "St. Valentine's Day"],
    [2, 20, "Washington's Day"],
    [5, 21, 'Memorial Day'],
    [6, 4, 'Independence Day'],
    [9, 3, 'Labour Day'],
    [11, 11, 'Veterans Day'],
    [11, 22, 'Thanks Giving Day'],
    [12, 25, 'Christmas'],
    [1, 7, 'Custom']
];

function nationalDays(date) {
    for (i = 0; i < natDays.length; i++) {
        if (date.getMonth() == natDays[i][0] - 1
                && date.getDate() == natDays[i][1]) {
            return [false, natDays[i][2] + '_day'];
        }
    }
    return [true, ''];
}

function noWeekendsOrHolidays(date) {
    var noWeekend = $.datepicker.noWeekends(date);
    if (noWeekend[0]) {
        return nationalDays(date);
    } else {
        return noWeekend;
    }
}


Drupal.behaviors.date_popup = function (context) {
    for (var id in Drupal.settings.datePopup) {
        $('#' + id).bind('focus', Drupal.settings.datePopup[id], function(e) {
            if (!$(this).hasClass('date-popup-init')) {
                var datePopup = e.data;
                // Explicitely filter the methods we accept.
                switch (datePopup.func) {
                    case 'datepicker':
                        $(this)
                                .datepicker({
                                                beforeShowDay: noWeekendsOrHolidays,
                                                minDate:+1,
                                                maxDate:"+3Y"
                                            })
                                .addClass('date-popup-init')
                        $(this).click(function() {
                            $(this).focus();
                        });
                        break;

                    case 'timeEntry':
                        $(this)
                                .timeEntry(datePopup.settings)
                                .addClass('date-popup-init')
                        $(this).click(function() {
                            $(this).focus();
                        });
                        break;
                }
            }
        });
    }
};
natDays=[
[1,1,‘新年’],
[1,16,“马丁·路德·金”],
[1,20,‘就职日’],
[2,14,“圣瓦伦丁节”],
[2,20,“华盛顿日”],
[5,21,‘阵亡将士纪念日’],
[6,4,‘独立日’],
[9,3,‘劳动节’],
[11,11,‘退伍军人日’],
[11,22,‘感恩节’,
[12,25,‘圣诞节’],
[1,7,‘定制’]
];
功能国家日(日期){
对于(i=0;i
如果他们为发布问题的OP工作,我看不出为什么不适合你。。。除非你向我们展示你正在尝试的代码并告诉我们什么不起作用,否则我尝试了你的链接,但它显然起作用了,但是如果将它与我的项目集成,它就不起作用了。