【问题标题】:FullCalendar scheduler update resource JSON objectFullCalendar 调度程序更新资源 JSON 对象
【发布时间】:2017-06-08 09:19:02
【问题描述】:

我正在使用 Rails 和 FullCalendar Scheduler,我希望能够在添加新对象时更新作为资源提供的 JSON 对象。

这是我的日历选项的简化版本:

fullcalendar-settings.js

$(document).ready(function() {
    $('#calendar').fullCalendar({
        header: {
            left: 'promptResource, prev, next, today',
            center: 'title',
            right: 'agendaWeek, timelineDay'
        },
        customButtons: {
          promptResource: {
              text: '+ maker',
              click: function() {
                  var name = prompt('Name');
                  if (name) {
                      $('#calendar').fullCalendar(
                          'addResource', { title: name }, true // scroll to the new source?
                      );
                  }
              }
          }
        },
        defaultView: 'timelineDay',
        defaultDate: moment(),
        editable: true,
        resourceColumns: [
            {
                labelText: 'Client',
                field: 'title'
            }
        ],
        resources: 'scheduler.json',
        events: []
    });
});

scheduler.json

[
  { "id": "1", "title": "LE" },
  { "id": "2", "title": "DB" },
  { "id": "3", "title": "VB" },
  { "id": "7", "title": "RL" }
]

资源是从“scheduler.json”加载的,我有一个按钮,您可以使用它添加新资源,但它现在只是临时的,在重新加载时会消失。

所以我的问题是当我添加新资源时如何更新“scheduler.json”中的 JSON 对象?

提前致谢

【问题讨论】:

  • 在日历中创建事件后,您必须发送一个 ajax 请求以更新您的数据库,这将在您下次重新加载页面时生成 scheduler.json 文件。
  • 我对 JSON 没问题,但不确定如何执行此类请求。

标签: javascript ruby-on-rails json fullcalendar fullcalendar-scheduler


【解决方案1】:

您需要学习 Jquery Ajax。您需要阅读 FullCalendar 的文档。没有其他办法。但是,如果您需要快速修复,您可以watch this screencast。我猜这肯定会满足您的要求。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-05
    • 2017-09-19
    • 1970-01-01
    • 1970-01-01
    • 2014-06-16
    • 1970-01-01
    相关资源
    最近更新 更多