FullCalendar.js: Rendering background with time labels?

雨燕双飞 提交于 2019-12-06 03:19:29

问题


I am starting to use Fullcalendar and love the docs. However, I am stuck with the following problem:

Rendering background with time labels?

I have one user specifying his available times, and another user who can do a selection out of those given times. To allow selection we need to set rendering: 'background' in the events array, otherwise the main event is blocking the event insert. But when using background rendering the time labels disappear:

So how can I tell Fullcalendar to keep on displaying those time labels even in background rendering mode?


I would be happy if somebody could help me out.


回答1:


Adding time labels to background events doesn't come "out of the box" but it's easy enough to do with the eventRender callback.

eventRender: function(event, element, view ){
    if(event.rendering === "background"){
        // Just add some text or html to the event element.
        element.append( event.start.format('HH:mm') + " - " + 
                       event.end.format('HH:mm'));
    }
},

You can of course add a span or two if you want better formatting.

Here's a JSFiddle with it working (Using the same base code as your other question)



来源:https://stackoverflow.com/questions/29824886/fullcalendar-js-rendering-background-with-time-labels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!