2017-01-24 155 views
-1

我想禁用日期和星期日和星期六數組..我的日期列表工作完美,但業務邏輯需要禁用星期日和星期六..如何做到這一點?Bootstrap - datesDisabled數組日期和星期日和星期六

這是我的日期陣列碼:

function checkDateFromForEvent() { 
var datesForDisable = new Array(); 

var clientContext = new SP.ClientContext.get_current(); 
var eventsList = clientContext.get_web().get_lists().getByTitle("Events"); 
var camlCheckQry = new SP.CamlQuery.createAllItemsQuery(); 
var items = eventsList.getItems(camlCheckQry); 

clientContext.load(items, "Include(EventDate)"); 

clientContext.executeQueryAsync(successHandler, errorHandler); 

function successHandler() { 
    if (items.get_count() > 0) { 
     var iEnum = items.getEnumerator(); 
     while (iEnum.moveNext()) { 
      var item = iEnum.get_current(); 
      datesForDisable.push(moment(item.get_item("EventDate")).format("DD-MM-YYYY")) 
     } 
    } 

    $("#holidayDateFrom").datepicker({ 
     format: 'dd/mm/yyyy', 
     autoclose: true, 
     language: 'bg', 
     weekStart: 1, 
     calendarWeeks: true, 
     todayHighlight: true, 
     datesDisabled: datesForDisable 
    }) 

我想在datesDisable paremeter,週日和週六插入..

回答

0

您可以使用beforeShowDay個掛鉤

$('#datepicker').datepicker({ 
    format: 'dd/mm/yyyy', 
     autoclose: true, 
     language: 'bg', 
     weekStart: 1, 
     calendarWeeks: true, 
     todayHighlight: true, 
     //datesDisabled: datesForDisable, 
     daysOfWeekDisabled: [0,6], 
     beforeShowDay:function(currentDate){ 
     var dayNr = currentDate.getDay(); 
      if (dayNr==0 || dayNr==6){//you can condition this with your own logic 
         return false; 
       } 
      return true;  
     } 
}); 
+0

您能插入我的數組作爲函數中的參數,並foreach每個元素? –

+0

函數(datesForDisable) –

+0

我有多個日期,我需要檢查..... –

0

使用daysOfWeekDisabled: [0,6]

$("#holidayDateFrom").datepicker({ 
     format: 'dd/mm/yyyy', 
     autoclose: true, 
     language: 'bg', 
     weekStart: 1, 
     calendarWeeks: true, 
     todayHighlight: true, 
     datesDisabled: datesForDisable, 
     daysOfWeekDisabled: [0,6] 
    }) 

演示here

+0

是的,但是這種固定daysOfWeekDisabled:[0,6],因爲我的公司有周六每天工作 –

+0

我需要激活日期 –

+0

烏爾問題尚不清楚.. u需要究竟 –

相關問題