2011-12-17 3 views
1

を返しません。私は、このシナリオをしました:最初にカレンダーの負荷refetchEventsを呼び出した後ClientEventsへを取得しようとすると、任意のClientEventsへに

と複数のイベントソースに基づいてイベントの束を示しています。また、ユーザーがいくつかの基準に基づいてカレンダーをフィルタリングできるドロップダウンボックスもあります。しかし、イベントソースからロードされたイベントの初期セットから常に作業を行うために、フィルタリングを開始する前に.fullCalendar( 'refetchEvents')コールを呼び出します。私はクライアントイベント(.fullCalendar( 'clientEvents'))を取得することでこれを行います。しかし、私が持っている問題は、refreshEventsを実行した後にクライアントイベントを取得したときに、その時点でカレンダーに多数のイベントが表示されていても、クライアントイベントは0件になるということです。何か不足していますか?お知らせ下さい。

コードスニペット:

$('#calendar').fullCalendar('refetchEvents'); //commenting this out, gives me the clientEvents 
var calEvents = $('#calendar').fullCalendar('clientEvents'); 
alert(calEvents.length + " and " + $.isArray(calEvents)); //get nothing here after refetchEvents 
if (ui.checked) { 
    $.ajax({ 
    type: "GET", 
    async: true, 
    url: "/Case/CalendarFilterCriteria", 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    data: { filterOptions: data, caseId: cavo.currentCaseId }, 
    success: function (response) { 
     //alert($.isArray(response.eventIds)); 
     $.each(calEvents, function (index, value) { 
     //alert(index + " and " + value.id); 
      $('#calendar').fullCalendar('removeEvents', function (value) { 
      var found = 0; 
      $.each(response.eventIds, function (index, val) { 
       console.log("value " + value.id + " val " + val.id); 
       if (value.id === val.id) { 
        console.log("match found"); 
        found = 1; 
        return false; //to break the inner .each loop 
       } 
      }) 
      console.log("remove " + !found); 
      return !found; //if true, the event will be deleted from the calendar 
     }) 
    }); 
}       

答えて

0

あなたの問題はrefetchEventsが非同期AJAX呼び出しを行っていることです。つまり、$('#calendar').fullCalendar('clientEvents')に電話すると必ずデータが取得されたわけではありません。

関連する問題