2017-11-20 24 views
1

私はフルテキストエディタとgoogleCalendarを統合するためにsymfony3プロジェクトに取り組んでいます。私はgooglecalendarを使ってfullcalendarをフィードしてgooglecalendarのすべてのイベントを表示し、それからfullcalendarでイベントを変更するたびにgooglecalendarで変更されます。だから、ステップは私がすでにやっているGoogleカレンダーからGoogleのイベントを取得することですし、私は、JSONの形式でそれを作るしようとしている:fullcalendarとの統合googleカレンダー

$ myjsonfile:

[{ 
"title": "Rdv Ecole", 
"start": "2017-11-13T10:00:00+01:00", 
"end": "2017-11-13T12:00:00+01:00" 
}, { 
"title": "testing functions", 
"start": "2017-11-20T13:15:00+01:00", 
"end": "2017-11-20T14:15:00+01:00" 
}, { 
"title": "another test", 
"start": "2017-11-20T17:30:00+01:00", 
"end": "2017-11-20T18:30:00+01:00" 
}, { 
"title": "reuinion data vc", 
"start": "2017-11-21T09:00:00+01:00", 
"end": "2017-11-21T10:00:00+01:00" 
}] 

すると、私はsymfony3を使用していますので、私イベントを表示するには

return $this->render('calendar/loadcalendar.html.twig',['gevents'=>$myjsonfile]); 

そして、私のページにします

$(document).ready(function() { 

     $('#calendar').fullCalendar({ 
      defaultView: 'agendaWeek', 
      header: { 
       left: 'prev,next today', 
       center: 'title', 
       right: 'month,agendaWeek,agendaDay' 
      }, 
      navLinks: true, // can click day/week names to navigate views 
      selectable: 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); // stick? = true 
       } 
       $('#calendar').fullCalendar('unselect'); 
      }, 

      eventLimit: true, // allow "more" link when too many events 
      eventSources: [ 
       { 
        url: "http://localhost/prog/web/app_dev.php/calendar/load", 
        dataType: "json", 
        method: 'GET' 
       } 
      ], 
      eventClick: function(event) { 

       var title = prompt('Change Event title:'); 
       event.title = title; 
       $('#calendar').fullCalendar('updateEvent', event); 

      } 
     }); 

問題は、私が送信したjsonからイベントを読み込むことができないので、誰かが私にいくつかのアドバイスを与えることができるということですか?おかげで私のプロジェクトで

+0

を、あなたは「できない」とはどういう意味ですか?イベントソースのURLは機能しませんか? fullCalendarで呼び出すとどうなりますか?コンソールのエラー、またはブラウザのネットワークタブにエラーがありますか?どんなサーバーのエラー? – ADyson

+0

これはエラーではなく、このURLでリクエストajaxをキャッチすることを示しています。http://localhost/prog/web/app_dev.php/calendar/load?start = 2017-11-20T00%3A00%3A00&end = 2017-11 -27T00%3A00%3A00&_ = 1511176051885 –

答えて

2

は、私はそれをこのように実行します。

$('#calendar').fullCalendar({ 
    /* [...] */ 
    events: "{{ path('ajax_calendar_load') }}", 
    /* [...] */ 

そして、私の負荷アクション・リターンの正規JSON:

$response = new JsonResponse(); 
    $response->setContent($events); 
    return $response; 
+0

ありがとうございます、あなたの答えは私に完璧です! –

関連する問題