2016-09-26 7 views
0

私はfull calendar plugin v3を使用しています。問題はremoveEventSource関数は私がパラメータを指定するときには機能しません。私はid、URLをparametresとして入れようとしましたが、refetchEventsを使用しましたが運がありません。イベントを削除しないフルカレンダープラグイン

$('#calendar').fullCalendar('removeEventSource'); //working without parameters 

$('#calendar').fullCalendar('removeEventSource', 1); //does not work 

配列:

var events = [ 
      { id: 1, 

       title: 'dinner', 
       start: '2016-09-14', 
       end: '2016-09-14' 
      }, 
      { id: 2, 
       title: 'All Day Event', 
       start: '2016-09-10', 
       end: '2016-09-10' 
      }, 
      { id: 3, 
       title: 'Long Event', 
       start: '2016-09-10', 
       end: '2016-09-10' 
      }, 
      { id: 4, 
       title: 'Repeating Event', 
       start: '2016-09-09T16:00:00', 
       end: '2016-09-09' 
      } 
     ] 

カレンダー

var calender = $('#calendar').fullCalendar({ 
    header: { 
    left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     defaultDate: '2016-09-12', 
     navLinks: true, 
     selectable: true, 
     droppable: true, 
     selectHelper: true, 
     select: function(start, end) { 
      var title = prompt('Event Title:'); 
      var eventData; 
      if (title) { 
       eventData = { 
        title: title, 
        start: start, 
        end: end 
       }; 
       $('#calendar').fullCalendar('renderEvent', eventData, true); 
      } 
      $('#calendar').fullCalendar('unselect'); 
     }, 
     drop: function() { 
      if ($('#drop-remove').is(':checked')) { 
       $(this).remove(); 
      } 
     } 
     , 
     editable: true, 
     eventLimit: true, 
     events : events 
    }); 

クリックイベント

$('body').on('click','.fc-close',function(e){ 
    //alert('remove event'); 
    $('#calendar').fullCalendar('removeEventSource', 1); 
    $('#calendar').fullCalendar('refetchEvents'); 



    }); 

答えて

1

intilizeあなたはeventSourcesevents上で少し混乱している、evenSourceですイベントのコレクションそのように渡すときにevents初期化にデフォルトのeventSourceは、idで初期化されています。なぜなら、idを渡さないとうまくいかないからです。正しい方法でeventSourceを渡します。

初期

var calender = $('#calendar').fullCalendar({ 
              //other stuff 
              eventSources : eventSrc 
              }); 

var eventSrc = [ 
       { 
        id:1, 
        events : [{        
           id: 1, 
           title: 'dinner', 
           start: '2016-09-14', 
           end: '2016-09-14' 
           }, 
           {  
           id: 2, 
           title: 'All Day Event', 
           start: '2016-09-10', 
           end: '2016-09-10' 
          }] 
       }, 
       { 
        id:2, 
        events : [{         
           id: 1, 
           title: 'camping', 
           start: '2016-08-14', 
           end: '2016-08-14' 
           }, 
           {  
           id: 2, 
           title: 'sports day', 
           start: '2016-08-10', 
           end: '2016-08-10' 
          }] 
       } 
       ] 

以下のようなそれぞれのEventSource項目にIDが今ちょうどそれを

を除去するためのEventSourceのIDを渡し
+0

ありがとう、それは働いた。 – nemrrached

関連する問題