fullcalendar今天之前变灰_在FullCalendar中禁用过去的日期

I started using the FullCalendar plugin recently. I am trying to implement a function on dropping events in the calendar. But before saving to the database, I want to check and disable/prevent dropping external events on dates before today.

Any idea on how to do this?? I am looking for something like the past days getting greyed-out or something like that so that I can display the events already present as well. Just want to prevent the user from dropping an event on a past date.

EDIT:

drop: function (date, jsEvent, ui) {

if(date

$('#calendar').fullCalendar('removeEvents', event.id);

}

I tried using this method to remove the dropped event from the calendar and to append it to the div again. Even then, it is not getting removed.

Thanks. :)

解决方案

eventConstraint can disable dragging and dropping outside of established boundaries

To gray out past days

/* SHADE DAYS IN THE PAST */

td.fc-day.fc-past {

background-color: #EEEEEE;

}

And for eventConstraint

/* This constrains it to today or later */

eventConstraint: {

start: moment().format('YYYY-MM-DD'),

end: '2100-01-01' // hard coded goodness unfortunately

}

For the 'end' of eventConstraint, you could add days to the current date if you like vs hard coded

EDIT:

To gray out time in the day view you can use businessHours

businessHours: {

start: moment().format('HH:mm'), /* Current Hour/Minute 24H format */

end: '17:00', // 5pm? set to whatever

dow: [0,1,2,3,4,5,6] // Day of week. If you don't set it, Sat/Sun are gray too

}

Dropping of external events onto the agendaDay in the past is allowed to occur. Editing the eventConstraint to include time will work 'YYYY-MM-DD HH:mm' but it prevents dropping on today in Month view...

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值