简体   繁体   English

如何更新FullCalendar事件

[英]How to update FullCalendar Events

I am attempting to set up a FullCalendar application that enables updates to newly-created calendar events. 我试图建立一个FullCalendar应用程序,以更新新创建的日历事件。 I found a demo on Codepen that uses the eventClick callback to facilitate this. 我在Codepen上找到了一个使用eventClick回调来简化此操作的演示。 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. 但是,我不明白为什么jsEvent参数似乎不包含在此回调中,而为什么该参数包含在函数标头中。 Is it necessary to write out jsEvent in: 是否有必要写出jsEvent:

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

or can jsEvent just be taken out? 还是可以将jsEvent取出? 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 这是文档: https : //fullcalendar.io/docs/eventClick

event is an Event Object that holds the event's information (date, title, etc). event是保存事件信息(日期,标题等)的事件对象。

jsEvent holds the jQuery event with low-level information such as click coordinates. jsEvent包含具有低级信息(例如单击坐标)的jQuery事件。

If you don't need access to the jQuery event in your eventClick , you can remove it. 如果您不需要在eventClick访问jQuery事件,则可以将其删除。

eventClick: function(calEvent) { ... }

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

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