简体   繁体   English

将虚拟事件添加到完整日历以创建广告位

[英]Adding dummy events to Full Calendar to make slots

Is there a way to add dummy events to Full calendar to divide each day into slots in month view, that is lets say i want three slots in a day nad there is space for 5 so i add an event, then add a dummy event which is transparent and doesn't show, then add event and so on so that there are three slots there. 有没有一种方法可以将虚拟事件添加到“全日历”,以在月视图中将每天划分为多个时段,也就是说,我希望一天中有三个插槽,并且没有空间可容纳5个,所以我添加了一个事件,然后添加了一个虚拟事件是透明的,不显示,然后添加事件,依此类推,以便在那里有三个插槽。 Is there a way to add the events in a loop or something, i can handle their sorting ie i just need to add two dummy events to each box and the rest will be done. 有没有一种方法可以将事件添加到循环中或类似的东西,我可以处理它们的排序,即我只需要向每个框中添加两个虚拟事件,其余的就可以完成。 So is there an easy way to do this short of making so many events and adding them with the real events? 那么,有没有一种简单的方法可以做到这一点,而不必制作那么多事件并将它们与真实事件相加?

EDIT : 编辑:

OK the given approach doesn't work because this way instead of making slots, it just occupies the first three positions, now if it were single day events and i added an event whose start time fell between the start times of the dummy events, it would automatically be placed between them, which is what i want to achieve. 好的,给定的方法行不通,因为这种方法不是占用时间,而是占据前三个位置,现在如果是单日事件,并且我添加了一个事件,其开始时间介于虚拟事件的开始时间之间,将自动放置在它们之间,这是我想要实现的。

It seems that your problem doesn't relate directly with "dummy" events. 看来您的问题与“虚拟”事件没有直接关系。 But, in any case, you can have arbitrary events created by a function you can use as the source of your events, which you can bind to the events property. 但是,在任何情况下,您都可以通过一个函数创建任意事件,该函数可用作事件的源,您可以将其绑定到events属性。

http://arshaw.com/fullcalendar/docs/event_data/events_function/ http://arshaw.com/fullcalendar/docs/event_data/events_function/

var calendar = $("#calendar").fullCalendar({
   // your calendar options (...)
   events: function(startDate, endDate, callback) {
              callback({title: "Dummy event",
              start: startDate,
              end: endDate});
   } 
)};

This function is going to be invoked when the calendar moves into another week or month, for example, returning a dummy event for the period. 当日历移动到另一个星期或一个月(例如,返回该期间的虚拟事件)时,将调用此函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM