Fullcalendar 在事件点击时获取资源 ID

2024-03-28

我正在使用全日历。一切工作正常,但在事件单击时未获取 Resourceid。这是我的代码:

        var date = new Date();
        var d = date.getDate() + 1;
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar({
            theme: true,
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,resourceDay'
            },
            defaultView: 'resourceDay',
            editable: false,
            droppable: false,
            slotDuration: '00:15:00',
            allDaySlot: false,
            resources: [
              {
                  'id': 'resource1',
                  'name': 'Resource 1'
              },
              {
                  'id': 'resource2',
                  'name': 'Resource 2'
              },
              {
                  'id': 'resource3',
                  'name': 'Resource 3'
              }
            ],
            resourceFilter: function(resource) {
                var active = $("input").map(function() {
                    return this.checked ? this.name : null;
                }).get();

                return $.inArray(resource.id, active) > -1;
            },
            events: [
              {
                  title: 'R1-R2: Lunch 12.15-14.45',
                  start: new Date(y, m, d, 12, 15),
                  end: new Date(y, m, d, 14, 45),
                  allDay: false,
                  resources: ['resource1', 'resource2', 'resource3']
              },
              {
                  title: 'R1: All day',
                  start: new Date(y, m, d, 10, 30),
                  end: new Date(y, m, d, 11, 0),
                  allDay: false,
                  resources: ['resource1', 'resource2', 'resource3']
              },
              {
                  title: 'R2: Meeting 11.00',
                  start: new Date(y, m, d, 11, 0),
                  allDay: false,
                  resources: 'resource2'
              },
              {
                  title: 'R1/R2: Lunch 12-14',
                  start: new Date(y, m, d, 12, 0),
                  end: new Date(y, m, d, 14, 0),
                  allDay: false,
                  resources: ['resource1', 'resource2', 'resource3']
              },
              {
                  id: 777,
                  title: 'R1: Lunch',
                  start: new Date(y, m, d, 12, 0),
                  end: new Date(y, m, d, 14, 0),
                  allDay: false,
                  resources: ['resource1', 'resource2', 'resource3']
              },
              {
                  title: 'R3: Breakfast',
                  start: new Date(y, m, d, 8, 0),
                  end: new Date(y, m, d, 8, 30),
                  allDay: false,
                  resources: ['resource1', 'resource2', 'resource3']
              },
              {
                  id: 999,
                  title: 'Repeating Event',
                  start: new Date(y, m, d - 3, 16, 0),
                  allDay: false,
                  resources: ['resource1', 'resource2', 'resource3']
              },
              {
                  id: 999,
                  title: 'Repeating Event',
                  start: new Date(y, m, d + 4, 16, 0),
                  allDay: false,
                  resources: ['resource1', 'resource2', 'resource3']
              }
            ],                
            // the ev.data is the resource column clicked upon
            selectable: false,
            selectHelper: true,
            select: function(start, end, ev) {
                console.log(start);
                console.log(end);
                console.log(ev.data); // resources
            },
            eventClick: function(event) {
                console.log(event);
            },
            eventDrop: function(event, delta, revertFunc) {
                console.log(event);
            }
        });

根据给定的图像,如果我单击第一列“资源 1”事件 [10:30 - 11:00 R1:全天],它应该在事件单击方法上获取该事件的 ResourceID“资源 1”。

Thanks


请更换你的select函数使用以下代码,您可以从资源参数中获取资源ID:

select: function(start, end, jsEvent, view, resource) {
      console.log(
        'select',
        start.format(),
        end.format(),
        resource ? resource.id : '(no resource)'
      );
    },
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Fullcalendar 在事件点击时获取资源 ID 的相关文章

随机推荐

  • 如何清理(用随机字节覆盖)std::string 内部缓冲区?

    考虑一个场景 其中std string用于存储a secret 一旦它被消耗并且不再需要 最好清理它 即覆盖包含它的内存 从而隐藏它secret std string提供一个函数const char data 返回指向 C 11 起 连续内
  • 根据匹配的列标题名称开头组合 R 中的列

    我有一个看起来有点像下面的数据框 A1U sweet 实际上是真实数据帧中的第 19 列 C1U sweet 是真实数据帧中的第 39 列 有 20 个以 A 开头的列和 20 个以 C 开头的列 A1U sweet A2F dip A3U
  • 在 Chapel 中使用矩阵创建域

    我有一个域名D 我想用它来索引几个矩阵A 某种形式的东西 var dom domain 1 0 5 var mats dom
  • 如何获取 PromptDialog.Choice 功能并仍然允许 Bot Framework 中的其他用户响应?

    Bot Framework 中的 PromptDialog Choice 提供了许多运行良好的内置功能 但是 我希望能够拦截 覆盖匹配过程 获得 PromptDialog Choice 功能并且还能够接受某些可能不匹配的字符串的最佳方法是什
  • 卡西尼号源代码下载链接?

    有谁知道哪里可以下载卡西尼号的源代码吗 我尝试了链接http www asp net Projects Cassini Download http www asp net Projects Cassini Download但该页面现在不存在
  • 如何从“struct linux_binprm”获取argv

    我想使用 bprm check security lsm 挂钩来检查是否允许运行具有特定参数的进程 在文档中 我看到 argv 应该在 bprm 类型为 struct linux binprm 中可用 但我没有找到任何从结构中提取 argv
  • 需要VC6平台SDK

    有谁知道我可以在哪里下载最后一个与 VC6 一起使用的 Platform SDK 我通过谷歌搜索找到的链接似乎都已失效 我设法在这里找到它 官方或非官方 http docs moodle org dev FebruaryPlatformSD
  • Gradle 日志在哪里?

    Android Studio 中应用程序的 Gradle 构建会生成以下错误 Error Execution failed for task app compileDebugJavaWithJavac gt java lang Runtim
  • 计算所有结构不同的二叉树的数量的时间复杂度是多少?

    使用此处介绍的方法 http cslibrary stanford edu 110 BinaryTrees html java http cslibrary stanford edu 110 BinaryTrees html java 12
  • 变量列表中的逗号是序列点吗?

    在以下类型的代码中 每个变量构造之间是否存在序列点 或者结果未定义 int a 0 int b a c a 我无法在标准中找到对此处序列点的具体引用 这是否意味着它未定义 或者只是我的搜索失败了 表达式的完成是一个序列点 但是上面的初始化也
  • 在 R 中为 pentium 4 HT 机器使用多核

    我在办公室使用Pentium 4 HT机器来运行R 一些代码需要plyr包 我通常需要等待6 7分钟才能完成脚本运行 而我看到我的处理器只使用了一半 我听说在 R 中使用多核包可以更好地利用多核处理器 我的情况适合吗 Thanks 有很多软
  • PyInstaller 2.1导入自定义包

    我有一个脚本正在尝试使用 Python 2 7 使用 PyInstaller 2 1 进行编译 该脚本使用我编写的名为 auto common 的自定义包 在脚本中 我使用以下命令导入它 sys path append path to pa
  • 如何在 Jupyter 中插入文字选项卡而不是自动完成?

    缩进整行很容易 Just highlight the whole line and press Tab Go to the start of the line and press Tab Click anywhere in the line
  • 如何获取枚举数

    如何获取枚举数 我有一个枚举 typedef enum DEL TIME VALUE 1 DEL TIMESEC VALUE 100 DEL TIMEMIN VALUE 200 DEL TIMEHOUR VALUE 300 DEL DAY
  • 用正则表达式获取最终的特殊字符

    我想要一个正则表达式 将字符串末尾的一些特殊字符分组 特殊字符是 和空格 例如 如果我有字符串 test 我想在组中获取字符串 我创建了以下正则表达式 问题是它给了我以下字符串 为什么要提取最后的括号 Put the 字符类中第一个或最后一
  • 循环选择某列并单独保存

    我的数据框是 c1 c2 c3 c100 0 2 0 4 0 9 0 0 2 0 3 0 1 0 1 0 6 1 0 3 我想选择c1 c2和c3 c1 c2和c4 类似的c1 c2和c100 每 3 个选定的列应保存在单独的文件中 我该怎
  • XNA 屏幕截图显示预绽放,而不是最终渲染

    我有一个使用 Reach 图形设置在 C XNA 4 0 中编码的 Windows 平台游戏 我的项目基于 GameStateManagement 示例 但后来我向其中添加了 Bloom 和 spriteSheet spriteBatch
  • Java Web 应用程序作为桌面应用程序,我应该选择哪些框架?

    我需要制作一个网络应用程序 我可以将其作为桌面应用程序安装在客户端 PC 上 数据库 jetty war firefox chrome sth 便携式 该应用程序是一个相当大的搜索应用程序 我必须使用 Lucene 只有几个屏幕 搜索队列中
  • 如何获得 makefile 函数来停止当前目标?

    我在 makefile 中有一个函数 如果文件不存在 或者至少是执行它的目标不存在 我想停止整个 make 运行 vaultfile vault shell test f 1 exit 1 define get token shell te
  • Fullcalendar 在事件点击时获取资源 ID

    我正在使用全日历 一切工作正常 但在事件单击时未获取 Resourceid 这是我的代码 var date new Date var d date getDate 1 var m date getMonth var y date getFu