user1499220
user1499220

Reputation: 419

cannot retrieve events from google calendar using fullcalendar

I followed the tuto about fullCalendar of Adam Shaw and I can't retrieve events from google calendar. Here is my code:

 <!DOCTYPE html>
    <html>
    <head>
    <link href="<?php echo css_url().'fullcalendar.css'; ?>" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<?php echo js_url().'jquery.js'; ?>"></script>
    <script type="text/javascript" src="<?php echo js_url().'fullcalendar.js'; ?>"></script>
    <script type='text/javascript' src='fullcalendar/gcal.js'></script>


    <script type='text/javascript'>

    $(document).ready(function() {

    // page is now ready, initialize the calendar...

    $('#calendar').fullCalendar({
        // put your options and callbacks here
    })

    });


    $(document).ready(function() {

      $('#calendar').fullCalendar({
          events: $.fullCalendar.gcalFeed(
             "http://www.google.com/calendar/feeds/username%40gmail.com/public/basic") 

    });

    });

    </script>

</head>
<div id='calendar'></div>
</html

Could you tell me what's wrong please?

Upvotes: 0

Views: 1423

Answers (1)

ganeshk
ganeshk

Reputation: 5621

You should instantiate the FullCalendar only once. Replace your script tag with this and it should work:

<script type='text/javascript'>
    $(document).ready(function() {
      $('#calendar').fullCalendar({
          events: $.fullCalendar.gcalFeed(
             "http://www.google.com/calendar/feeds/username%40gmail.com/public/basic") 
      });
    });
</script>

Let me know if this helps.

EDIT: Fiddle - http://jsfiddle.net/100thGear/JeDFG/. Also, please make sure gcal.js is in the correct path and is included in your HTML

Upvotes: 1

Related Questions