我想禁用日期和星期日和星期六的数组。我的日期工作完美,但业务逻辑需要禁用星期日和星期六..如何做到这一点?
这是我的日期数组代码:
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,sunday和Saturday Saturday中插入..
答案 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
答案 1 :(得分:0)
您可以使用beforeShowDay hook
$('#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;
}
});