2016-09-21 178 views
1

我不知道如何在fullcalendar scheduler.js中添加事件,任何人都可以帮助我吗?如何使用scheduler.js在fullcalendar中添加事件?

我可以使用fullcalendar添加事件,但没有可用的scheduler.js。

当我将此代码添加到我的脚本的事件将不会增加

select: function(start, end) 
{ 
    this.title = prompt('Event Title:'); 
    this.eventData; 
    if (this.title) { 
     this.eventData = { 
      title: this.title, 
      start: start, 
      end: end 
     }; 
     $('#calendar').fullCalendar('renderEvent', this.eventData, true); // stick? = true 
    } 
    $('#calendar').fullCalendar('unselect'); 
}, 

回答

1

你需要下载资源,并指定自己活动的资源ID为好。所以如果你把这些都解决了。试试这个代码。

select: function(start, end) 
    { 
     this.title = prompt('Event Title:'); 
     this.eventData; 
     if (this.title) { 
      this.eventData = { 
       title: this.title, 
       start: start, 
       end: end, 
       resourceId:['ResourceID1'] // Example of resource ID 
      }; 
      $('#calendar').fullCalendar('getResources')// This loads the resources your events are associated with(you have toload your resources as well) 
      $('#calendar').fullCalendar('renderEvent', this.eventData, true); // stick? = true 
     } 
     $('#calendar').fullCalendar('unselect'); 
    }, 

资源实例如下:

$('#calendar').fullCalendar({ 
header: {left: 'prev,next today', center: 'title', right: ''}, 
        selectable: true, 
allDayDefault: false, 
unselectAuto: false, 
editable: false, 
slotLabelFormat:"HH:mm", 
resources: [[id:'ResourceID1', title:"Just a title"],[id:'ResourceID2', title:"Just a title part II"]] 
})