【问题标题】:Full Calendar JS wrap time from end of business day to start of next business day从工作日结束到下一个工作日开始的完整日历 JS 包装时间
【发布时间】:2012-09-06 15:40:11
【问题描述】:

我在 AgendaWeek 视图中使用完整日历 JS,我将可见时间限制为上午 8 点至下午 5 点,而不是默认显示的每天完整的 12 小时,但是当我尝试扩展事件的时间并将其拖过去时可见时间的结束,它不会包裹到第二天。相反,它一直持续到午夜才结束。

有没有简单的方法来防止这种情况?基本上我只希望它显示一周中上午 8 点到下午 5 点之间的事件。

这是我的代码:

$('#calendar').fullCalendar({
  defaultView: 'agendaWeek',
  allDaySlot: false,
  minTime: '8:00am',
  maxTime: '6:00pm',
  weekends: false,
  header: {
    left: 'prev,next',
    center: 'title',
    right: ''
  },
  editable: true,
  droppable: true, // this allows things to be dropped onto the calendar !!!
  events: "{{URL::to('schedule/fetch')}}"
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.0/fullcalendar.min.js"></script>

我的事件以 UTC 格式存储在数据库中,只有开始时间和持续时间。要获得结束时间,我只需添加开始时间和持续时间,然后通过 AJAX 将其传回。我想如果它溢出到第二天,我需要让完整日历简单地添加到持续时间,但我只是不确定如何完成这个。

【问题讨论】:

    标签: javascript jquery fullcalendar fullcalendar-3


    【解决方案1】:

    我在完整日历的选择中使用以下解决方案:

    select: function(start, end) {
    
         if(start.format() > minTime && start.format() <  maxTime){
    
           eventId++;               
           var event = {
              id : eventId,
              start:  moment(start.format()),
              end:   moment(end.format())
           };
           $('#calendar').fullCalendar('renderEvent', event, true); 
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-14
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多