• fullcalendar从后台获取events报Uncaught TypeError: callback is not a function


            今天恰逢1024程序员节,祝包括自己在内的程序员们身体健康,收入多多!

      用fullcalendar做了一个简单的工作日和休息日的排班功能,因为现公司是大小休模式,即一周双休一周单休。把是否上班设置为event的title,events从后台获取:

     1             //获取数据后显示在fullcalendar页面
     2             events: function(start, end, callback) {
     3                 var fstart = moment(start).format("yyyy-MM-dd");
     4                 var fend = moment(end).format("yyyy-MM-dd");
     5                 $.ajax({
     6                     type: "post",
     7                     url: "/system/getWorkdayInfos",
     8                     dataType: "json",
     9                     data: {
    10                         start: fstart,
    11                         end: fend
    12                     },
    13                     success: function(data) {
    14                         if (data.success) {
    15                             var events = [];
    16                             $.each(data.data, function(i) {
    17                                 var status = data.data[i].workStatus==1?"班":"休";
    18                                 events.push({
    19                                     title: status,
    20                                     start: moment(data.data[i].date).format("YYYY-MM-DD"),
    21                                     end: moment(data.data[i].date).format("YYYY-MM-DD"),
    22                                     allDay: true
    23                                 });
    24                             });
    25                             callback(events);
    26                         } else {
    27                             alert(data.description);    
    28                         }
    29                     }
    30                 });
    31             },

      运行总是报错:

        

      搜索发现本人用的fullcalendar版本的events方法缺少一个参数:timezone,参考网页:https://bbs.csdn.net/topics/392283087?mType=Group。添加该参数后,果然不再报错。正确的events方法定义为:

    events: function(start, end, timezone, callback) {
      ...  
    }
  • 相关阅读:
    linux 下安装nodejs,CentOS 6.5 系统
    nginx 做负载均衡
    windows 下安装nginx
    Markdown 添加空行 空格
    Latex 部分语法
    中国古代文学史——先秦(原始歌谣、神话、《诗经》、《尚书》、《春秋》、《国语》、《左传》、《战国策》、诸子散文、楚辞)
    图论学习笔记
    集合论学习笔记
    Office 365 Word 打开网上下载文件出现错误
    路径规划基础知识
  • 原文地址:https://www.cnblogs.com/GreenMountain/p/9841899.html
Copyright © 2020-2023  润新知