如何更新FullCalendar事件 [英] How to update FullCalendar Events

查看:482
本文介绍了如何更新FullCalendar事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个FullCalendar应用程序,该应用程序可以更新新创建的日历事件.我在Codepen上找到了一个使用eventClick回调来简化此操作的演示.但是,我不明白为什么jsEvent参数似乎不包含在此回调中,而为什么在函数标头中包含了jsEvent参数.是否有必要在以下位置写出jsEvent:

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

还是可以将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);
    }
  });
});

推荐答案

以下是文档: https://fullcalendar .io/docs/eventClick

event是一个事件对象,用于保存事件的信息(日期, 标题等).

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

jsEvent包含具有低级信息的jQuery事件,例如 点击坐标.

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

如果您不需要访问eventClick中的jQuery事件,则可以将其删除.

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

eventClick: function(calEvent) { ... }

这篇关于如何更新FullCalendar事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆