fullcalendar今天之前变灰_如何使用arshaw fullcalendar v2.3.0在AgendaDay视图中将非工作日变为灰色...

I am using the latest version of arshaw fullcalendar (version 2.3.0) and have a scenario where a calendar needs to show active working days and hours.

Ive done this using:

businessHours:

{

start: '08:00',

end: '17:00',

dow: [2,3,4,5,6,0] // Monday is not a working day

},

In agendaWeek view, it clearly shows the working days with the non working days 'greyed out'. In my case, Monday

But when I go to agendaDay view, Monday, which is not defined as a working day shows no greyed out sections and the entire day is white, making it look like a working day.

Shouldn't the entire day in agendaDay view be greyed out if the day is not specified to be a working day?

解决方案

I think this is a bug but I created a workaround. It creates a background event when fullcalendar is in the agendaDay view and the current day is not in the DateOfWeek array.

$('#calendar').fullCalendar({

businessHours: {

start: '08:00',

end: '17:00',

dow: [0, 2, 3, 4, 5, 6]

},

viewRender: function (view, e) {

var bh = view.options.businessHours,

startDate = view.start;

if (view.type === "agendaDay" && bh.dow.indexOf(startDate.day()) === -1) {

$('#calendar').fullCalendar('renderEvent', {

start: moment(startDate),

end: moment(view.end),

rendering: 'background',

className: 'fc-nonbusiness'

}, false);

$('#calendar').fullCalendar('renderEvent', {

start: moment(startDate),

allDay: true,

rendering: 'background',

className: 'fc-nonbusiness'

}, false);

}

}

});

There are a few things that can be improved:

The selector $('#calendar') can be something generic.

When you access the day multiple times, .fullCalendar('renderEvent', will append multiple background events.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值