简体   繁体   中英

How to update FullCalendar Events

I am attempting to set up a FullCalendar application that enables updates to newly-created calendar events. I found a demo on Codepen that uses the eventClick callback to facilitate this. However, I don't understand why the jsEvent parameter is included in the function header, when it doesn't look like it is actually used inside this callback. Is it necessary to write out jsEvent in:

eventClick: function(calEvent, jsEvent) {...}

or can jsEvent just be taken out? Here is the code:

    $(document).ready(function() {
  $("#calendar").fullCalendar({
    header: {
      left: "prev,next today",
      center: "title",
      right: "month,agendaWeek,agendaDay"
    },
    defaultView: "month",
    navLinks: true, // can click day/week names to navigate views
    selectable: true,
    selectHelper: false,
    editable: true,
    eventLimit: true, // allow "more" link when too many events

    select: function(start, end) {
      var title = prompt("Event Content:");
      var eventData;
      if (title) {
        eventData = {
          title: title,
          start: start,
          end: end
        };
        $("#calendar").fullCalendar("renderEvent", eventData, true); // stick? = true
      }
      $("#calendar").fullCalendar("unselect");
    },

    eventRender: function(event, element) {
      element
        .find(".fc-content")
        .prepend("<span class='closeon material-icons'>&#xe5cd;</span>");
      element.find(".closeon").on("click", function() {
        $("#calendar").fullCalendar("removeEvents", event._id);
      });
    },

    eventClick: function(calEvent, jsEvent) {
      var title = prompt("Edit Event Content:", calEvent.title);
      calEvent.title = title;
      $("#calendar").fullCalendar("updateEvent", calEvent);
    }
  });
});

Here's the documentation: https://fullcalendar.io/docs/eventClick

event is an Event Object that holds the event's information (date, title, etc).

jsEvent holds the jQuery event with low-level information such as click coordinates.

If you don't need access to the jQuery event in your eventClick , you can remove it.

eventClick: function(calEvent) { ... }

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