3

I'm having issues attaching events from a json file to the calendar. The calendar successfully builds but doesn't append the events.

I uploaded the json file for you guys to view: https://api.myjson.com/bins/1dfki

HTML:

<html>
<head>
    <title>Bootstrap Calendar</title>

    <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="style.css">

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment.min.js"></script>

<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.0.2/fullcalendar.min.js"></script>

    <script type="text/javascript" src="script.js"></script>

</head>
<body>
<div id="calendar"></div>

</body>
</html>




$(document).ready(function() {

$('#calendar').fullCalendar({
events: 'https://api.myjson.com/bins/1dfki'
    });

});
2
  • The first thing I would do would be to make sure the cross site request is working. Use jQuery to load api.myjson.com/bins/1dfki - plus i'm not sure how cross site request work with https. See what's happening using your browser debug tools. If that is working, then try again with the simplest feed or a demo feed you know works.
    – bryjohns
    Commented Jul 10, 2014 at 18:49
  • @bryjohns So from looking at my json the structure should be fine? I've been trying to follow the documentation but there isn't much regarding events and json
    – Dondada
    Commented Jul 10, 2014 at 18:56

1 Answer 1

1

According to the documentation JSON feed is expected to be an array of Event objects. http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/ - first sentence. I made an example feed using the data you provided in yours (modified so it had 3 real dates). https://api.myjson.com/bins/1zibm. You tried to make an Agenda object but it just expects Event objects in an array.

2
  • Something is showing now, which is great! But how do I show the objectTitle on the date's square.
    – Dondada
    Commented Jul 11, 2014 at 13:03
  • 1
    @Dondada it should be title not objectTitle. Have some examples and JSON feeds at mikesmithdev.com/examples/calendar.aspx. Commented Jul 11, 2014 at 16:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.