如何渲染事件以使用fullcalendar填充day元素

时间:2011-07-27 14:42:04

标签: fullcalendar

只是想知道是否有人有更好的方法在fullcalendar js中设置一整天的背景?我的方法的问题是,如果你转到日历中的另一个页面,表格单元格背景仍然会改变。我可以重置fullCalendar('prev')事件中的所有背景我猜,但这看起来很混乱。任何人都知道如何渲染实际事件以使其扩展以填满整天?

var trainingDiary = $("#training_diary").fullCalendar({
  dayClick: function(date, allDay, jsEvent, view) {

    var title = prompt('Event Title:');
    var dayObj = $(this);
    //console.log($(this));
    if (title) {
     $.ajax({
      url: "/app_dev.php/addtrainingday",
      global: false,
      type: "POST",
      data: "dayNo=" + date.getDate(), //returns day of month. getDay() returns day of week
      async:true,
      success: function(msg) {

               trainingDiary.fullCalendar('renderEvent',
                {
                  title: title,
                  start: date,
                  allDay: allDay,
                  backgroundColor:'#cccccc'
                },
            true // make the event "stick" across calendar pages
          )

      dayObj.css({'background-color':'#339933','background-image':'url()'})
      console.log(msg.valueOf());
      } //end ajax success
     })
   } else {
      trainingDiary.fullCalendar('unselect');
   }

  },
  //selectable:true,
  //selectHelper:true,
  theme: true,
  header: {left:'title',
            center: '',
            right: 'today prev next'},
  firstDay:1

});

1 个答案:

答案 0 :(得分:1)

看起来可以使用eventRender()回调来完成。 http://arshaw.com/fullcalendar/docs/event_rendering/eventRender/