title: Creating events on multiple calendars with FullCalendar.js
body: <p>I am using the FullCalendar javascript library on my web site to display a calendar for each employee side-by-side. The calendar displays the Day view so it's easy to see everyones schedule for the day. </p>
  
  <p>I have all of the calendars displaying properly side-by-side (each in their own div). </p>
  
  <p>My problem is, when creating a new event by clicking on the calendar, the event always gets created on the last calendar on the page instead of the actual calendar you click on. I have a feeling it has to do with closure in the select callback function.</p>
  
  <pre><code>/*
  *   Setup calendars for each sales person
  */
  var d = $.fullCalendar.parseDate($("#requested_date").val());
  
  //employee id numbers (each employee has own calendar)
  var employees = new Array(445,123,999,444); 
  
  for(i=0;i&lt;employees.length;i++)
  {
          var employeeId = employees[i];
  
          //clear any prevoius calendar info
          $('#calendar_' + employeeId).html("");
  
          calendar[employeeId] = $('#calendar_' + employeeId).fullCalendar({
              header: {
                  left: '',
                  center: '',
                  right: ''
              },
              year: d.getFullYear(),
              month: d.getMonth(),
              date: d.getDate(),
              defaultView: 'agendaDay',
              minTime: 7,
              maxTime: 19,
              height: 650,
              editable: true,
              selectable: true,
              selectHelper: true,
              select: function(start, end, allDay) { 
  
                  calendar[employeeId].fullCalendar('renderEvent',
                      {
                          title: "This Estimate",
                          start: start,
                          end: end,
                          allDay: allDay
                      },
                      true // make the event "stick"
                  );
  
                  calendar[employeeId].fullCalendar('unselect');
              },
              events: {
                  url: 'calendar/'+employees[employeeId],
                  type: 'POST',
                  data: {
                          'personId': employees[employeeId],
                          'ci_csrf_token': wp_csr_value
                      },
                  error: function() {
                  alert('there was an error while fetching events!');
              }
          }
      });
  }
  </code></pre>
  
  <p>Thanks</p>