Fullcalendar: Events with open and closed day background/marker
I was building a Calendar with dynamic events.
Simplest representation of my event object id : " sdsddsd " start : "2018-05-13T0..." end : "2018-05-26T0" open_monday: true open_tuesday: false open_wednesday: true open_thursday: false ...
So in the month view calendar, I wanted to show my events and within the event if open_monday
is true then set the background of that day grid to green. The following Tuesday will use the value open_tuesday
and it is false so it will display red.
The red and green background will only be inside an Event. If the day grid isn't within any event, it will be left as blank.
How can I do this. Or is there a better way to do this using resources
, constraints
etc. ?.
Thanks.
I am not sure I understand, but it is rather strange to pass the whole list of open/closed weekdays with each event. You should rather determine which weekday your event is and act accordingly. Just add an eventRender callback field to your calendar to control exactly the layout of the HTML element rendering the event. See https://fullcalendar.io/docs/eventRender
To know the weekday of an event, use
moment(event.start).day()
See https://momentjs.com/docs/#/get-set/day/
Alternatively, you can add an eventDataTransform field to your calendar, which will be applied to each event when it is loaded, so you can change any of its layout specifiers (color, backgroundColor, className...), see list at https://fullcalendar.io/docs/event-object
链接地址: http://www.djcxy.com/p/81170.html