How to update FullCalendar Events

非 Y 不嫁゛ 提交于 2019-12-24 11:28:37

问题


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);
    }
  });
});

回答1:


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) { ... }


来源:https://stackoverflow.com/questions/54856344/how-to-update-fullcalendar-events

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