日期选择器 - 使用默认的功能使用自定义功能

问题描述:

目前,我有这样的自定义函数:日期选择器 - 使用默认的功能使用自定义功能

var $myBadDates = new Array(<?php foreach($aryDates as $disabledate) { echo ' "$disabledate",'; } echo " 1"; ?>); 
// Creates the array (The echo " 1"; is merely to close the array and will not affect the outcome 
function checkAvailability(mydate) { 
    var $return = true; 
    var $returnclass = "available"; 
    $checkdate = $.datepicker.formatDate('yy-mm-dd', mydate); 
    for (var i = 0; i < $myBadDates.length; i++) { 
     if ($myBadDates[i] == $checkdate) { 
      $return = false; 
      $returnclass = "unavailable"; 
     } 
    } 
    return [$return, $returnclass]; 
} 

的日期选择器部分都按这样的:

$(function() { 
    //To enable End Date picker only when Start Date has been chosen (And to disable all dates prior of said date) 
    var end = $('#enddate').datepicker({ 
     numberOfMonths: 3, 
     stepMonths: 3, 
     beforeShowDay: checkAvailability 
    }); 
    // Defining a function, because we're binding this to two different events 
    function enableEnd() { 
     end.attr('disabled', !this.value.length) // Enable the end input element if the first one has anything in it 
     .datepicker('option', 'minDate', this.value); // Set the minimum date to the date in the first input 
    } 
    //End of function 
    // Datepicker 
    $('#startdate').datepicker({ 
     numberOfMonths: 3, 
     stepMonths: 3, 
     beforeShowDay: checkAvailability, 
     minDate: +1, 
     onSelect: enableEnd // Call enableEnd when a date is selected in the first datepicker 
    }).bind('input', enableEnd); // Do the same when something is inputted by the user 
    //hover states on the static widgets 
    $('#dialog_link, ul#icons li').hover(

    function() { 
     $(this).toggleClass('ui-state-hover'); 
    }); 
}); 
//End of Function​ 

我做的是从我的SQL DB中,我使用了一个自定义函数,将开始日期和结束日期更改为日期数组,然后将它们推入单个数组中,并用于禁用所述日期。
第二个日期选择器仅在来自第一个日期选择器的有效日期返回为TRUE时启用。

现在的问题是这样的:
我可以*所有日期,我必须。大。但现在,我怎样才能在这个周末屏蔽周末呢?
beforeShowDay: $.datepicker.noWeekends无法工作,因为我已经在使用自定义函数。所以,我必须进一步定制我的自定义功能。我不能使用getDate()并显示> 0和< 7,那么我该如何解决这个问题?

任何帮助,甚至小费的答案都会有所帮助。我一直在尝试这一点,而且我没有到任何地方。谢谢。

+0

'GETDATE()'将无法工作。即使创建一个重复相同过程的函数也是行不通的。 – 2011-01-26 10:36:26

似乎很简单,但我不明白为什么你不能使用getDay()功能:

function checkAvailability(d) { 
    if (
     d.getDay() == 6 /* saturday */ || 
     d.getDay() == 0 /* sunday */ 
    ) { 
     return [false,'unavailable unavailable-cuz-its-weekend']; 
    } 
    $checkdate = $.datepicker.formatDate('yy-mm-dd', d); 
    for (var i = 0; i < $myBadDates.length; i++) { 
     if($myBadDates[i] == $checkdate) 
     { 
      return [false, "unavailable"]; 
     } 
    } 
    return [true, "available"]; 
} 
+0

正如我所说,它不会工作。 – 2011-01-29 05:22:37