简体   繁体   中英

How to extend fullCalendar.js end date using Javascript?

I have the same problem as this guy. I don't know how to increase the end date by one day. I don't want to change its value in the database, just on the html page.

Here's my calendar at the moment (no Moment.js pun):

$(document).ready(function () {

   // page is now ready, initialize the calendar...
   var base_url = '{{ url('/') }}';
   var $calendar = $('#calendar-holidays').fullCalendar({
   header: {
      left: '',
      center: 'title',
      right: ''
      },
   weekends: false,
   editable: false,
   eventLimit: true,
   events: {
      url: base_url + '/holidayapi',
      error: function () {
         alert("cannot load holidays from database");
      },
   }
});

If your event objects have end specified

$('#calendar').fullCalendar({
  /* assumes end is set in event object! */
  eventDataTransform: function(event) {
    var copy = $.extend({}, event);
    copy.end = moment(event.end).add(1, 'day'); // make moment in case it isn't already
    return copy;
  },
  events: [{ /* sample event */
    start: moment().format('YYYY-MM-DD'),
    // all day event, assumes end to be next day @ 00:00
    end: moment().add(1,'day').format('YYYY-MM-DD'),
    title: 'Today event'
  }]
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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