最近使用fullCalendar与后台java结合遇到的各种‘坑’

项目组要使用到日程管理,fullCalendar确实为一个不错的选择。但是在运用过程中有不少问题!下图为最终版。

最近使用fullCalendar与后台java结合遇到的各种‘坑’1.路径没有配置正确,报错。 $('#calendar').fullCalendar({}),  undefined.(这是由于路径我的问题 啊1!!!!)

2.这个插件是基于 jquery的,所以的配置jquery.js(版本自己定,下面我自己用的),否则报错  e  is not  undefined(插件里面的 变量  找不到)

最近使用fullCalendar与后台java结合遇到的各种‘坑’

3.接收返回的  json数组(下面是我返回格式)

最近使用fullCalendar与后台java结合遇到的各种‘坑’

4.接下来用  自带方法的接收参数

最近使用fullCalendar与后台java结合遇到的各种‘坑’

js代码:

<script>

  $(document).ready(function() {
    initThemeChooser({
      init: function(themeSystem) {
        $('#calendar').fullCalendar({
          themeSystem: themeSystem,
          header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listMonth'
          },
          weekNumbers: false,
          navLinks: true, // 字下面的下划线
          editable: false,//对日程进行拖动
          eventLimit: true, //false时,把一天所以日程全部显示
          events : function(start,end, timezone,callback){
              var date = this.getDate().format("YYYY-MM");
              $.ajax({
              url:"${basePath}/ (action)  .do?action=方法名",
              data: {"month":date},
               cache:false,
                dataType: "json",
                 success:function(res){
                     var events =[];
                     if(res.status==1){                   
                         for(i in res.data){
                                 events.push({
                                     id:res.data[i].id,
                                     title:res.data[i].title,
                                     start:new Date(res.data[i].start),
                                     end:new Date(res.data[i].end),
                                    // end:new Date((new Date(res.data[i].end)/1000+86400)*1000),
                                 });
                         }
                     }else {
                       
                     }
                     callback(events);
                 },
                color:'yellow',// 背景色
                textColor:'black'// 文字颜色
              });
              }
        });
      },
        
      change: function(themeSystem) {
        $('#calendar').fullCalendar('option', 'themeSystem', themeSystem);
      }

    });

  });

</script>



有什么需要的 可以留言!