2016-09-13 9 views
0

最初にカレンダーを読み込むと、すべての見出し/ボタンが表示されますが、実際のカレンダーは表示されません。今日のカレンダーにカレンダーをロードするには、「今日」のボタンを押す必要があります。どのように初期の負荷でこれを行うにはどのようなアイデア?それが助けになるなら、ここで私が使っているコードがあります。私はここで何が起こっているかについてはかなり断りません、私はこの作品を他の誰かから継承しました、これはこのfullcalenderアドオンを見るのは初めてのことです。初期レンダリング時にカレンダーを表示するには、どのようにフルカレンダーを取得しますか?

function calendar() { 

    //gets saved events 
    var sourceFullView = { url: '/Calendar/GetDiaryEvents/' }; 
    var sourceSummaryView = { url: '/Calendar/GetDiarySummary/' }; 
    var CalLoading = true; 
    $('#calendar').fullCalendar({ 
     header: { 
      left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     defaultView: 'agendaWeek', 
     editable: true, 
     allDaySlot: false, 
     selectable: true, 
     slotMinutes: 15, 
     events: '/Calendar/GetDiaryEvents/', 
     eventClick: 
      function(calEvent) { 
       //modal located at the bottom of the page 
       var modalElementId = $("#modal"); 
       //url located in the Calendar controller. CalEvent Id referes to event id 
       var url = GetUrlPath() + '/Calendar/OpenDetailsModal?id=' + calEvent.id; 
       var appointmentId = calEvent.id; 
       //These are defined at the top of the page 
       $('#DiaryEventID').val(appointmentId); 
       $('#DiaryEventID').val(""); 
       var viewModel = new CalenderViewModel(appointmentId); 
       showEditModal(null, viewModel, url, modalElementId); 
       $('.modal-backdrop').removeClass('modal-backdrop'); 
      }, 

     eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc) { 
      if (confirm("Confirm move?")) { 
       UpdateEvent(event.id, event.start); 
      } else { 
       revertFunc(); 
      } 
     }, 

     eventResize: function(event, dayDelta, minuteDelta, revertFunc) { 
      if (confirm("Confirm change appointment length?")) { 
       UpdateEvent(event.id, event.start, event.end); 
      } else { 
       revertFunc(); 
      } 
     }, 

     dayClick: function(date, allDay, jsEvent, view) { 
      $('#eventTitle').val(""); 
      setTimeout(ShowClientEventModal(), 100); 
      for (i = 0; i < 2; i++) { 
       if (date != "") { 
        $('#eventClientDate').val($.fullCalendar.formatDate(date, 'dd/MM/yyyy')); 
        $('#eventClientTime').val($.fullCalendar.formatDate(date, 'HH:mm')); 
        $("#eventClientDate").datepicker({ dateFormat: 'dd/mm/yy' }); 
       } 
      } 
     }, 

     viewRender: function(view, element) { 

      if (!CalLoading) { 
       if (view.name == 'month') { 
        $('#calendar').fullCalendar('removeEventSource', sourceFullView); 
        $('#calendar').fullCalendar('removeEvents'); 
        $('#calendar').fullCalendar('addEventSource', sourceSummaryView); 
       } else { 
        $('#calendar').fullCalendar('removeEventSource', sourceSummaryView); 
        $('#calendar').fullCalendar('removeEvents'); 
        $('#calendar').fullCalendar('addEventSource', sourceFullView); 
       } 
      } 
     } 
    }); 
    CalLoading = false; 
} 

ビット詳細は、これは奇妙ですが、私は、開発者ツールに行くために、ブラウザ上でF12キーを押したときに、私は今日のボタンを押したかのように、そしてカレンダーが突然レンダリングします。しかし、すでに開いているデバッガを使用してカレンダーページに入ると、カレンダーの内容がないヘッダーがレンダリングされます。一体何が起こっているの?

答えて

0

CalLoadingに関連するすべてのコードを削除することをおすすめします。そのため、変数割り当てを上から削除し、viewRender関数全体を削除し、変数割り当てを末尾のfalseに削除してください。それは、それらがすべてロードされるか、またはそのようなものになるまで、イベントを表示しないためのいくつかのタイプの関数のように見え、私の推測は正しく機能していないと思われます。

編集:関数はそうまだsourceFullViewにカレンダーのデフォルトを持つことになり、これを削除し、月ビューにsourceSummaryViewにイベントソースをスワップ・アウト、および他のsourceFullViewように見えますが、私は2の違いを知りませんあなたはそれがどのように動作するか試してみる必要があります。

var CalLoading = true; 

viewRender: function(view, element) { 
    if (!CalLoading) { 
     if (view.name == 'month') { 
      $('#calendar').fullCalendar('removeEventSource', sourceFullView); 
      $('#calendar').fullCalendar('removeEvents'); 
      $('#calendar').fullCalendar('addEventSource', sourceSummaryView); 
     } else { 
      $('#calendar').fullCalendar('removeEventSource', sourceSummaryView); 
      $('#calendar').fullCalendar('removeEvents'); 
      $('#calendar').fullCalendar('addEventSource', sourceFullView); 
     } 
    } 
} 

CalLoading = false; 
関連する問題