2016-09-21 182 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"]] 
})