2012-10-26 46 views
0

我有這個代碼,我想限制選項只有選定的日子由診所。beforeShowDay()jQuery的日期選擇器,限制天不顯示

http://jsfiddle.net/pypbc/10/

$("#datepicker").datepicker({ 
    dateFormat: "yy-mm-dd", 
    numberOfMonths: 3, 
    showButtonPanel: true, 
    beforeShowDay: function(date) { 

     var day = date.getDay(); 
     var clinic = $("#AppointmentClinicId").val(); 

     console.log("day:" + day); 
     console.log("selected clinic:" + clinic); 

     if (clinic == 1) { 
      return [(date.getDay() == 1), ""]; 
     } 

     if (clinic == 2) { 
      return [(date.getDay() == 2), ""]; 
     } 

     if (clinic == 3) { 
      return [(date.getDay() == 3), ""]; 
     } 

     if (clinic == 4) { 
      return [(date.getDay() == 4), ""]; 
     } 

     if (clinic == 5) { 
      return [(date.getDay() == 5), ""]; 
     } 

     if (clinic == 6) { 
      return [(date.getDay() == 6), ""]; 
     } 

     /*if (clinic == 0) { 
      return [true, ""]; 
     }*/ 

     //return [true,'']; 
    } 
}).val(); 

但是,它始終顯示爲0診所,總是返回false。如果你在beforeShowDay之前刪除它,它會起作用。我知道「返回[true,''];」,如果我只有這個,它就可以工作。但是,不知道爲什麼它沒有正確選擇診所來顯示允許的日期。

請幫忙!

回答

-1

您要使用的功能是不是beforeShowDayonBeforeShowDay

+0

我真的相信這是beforeShowDay。 –

+0

我已經測試過它,它在onBeforeShowDay ..之前投票下來你應該測試它! –

相關問題