My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 979: start and end properties of event incorrect when creating recurring events in select callback.
2 people starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  Aug 2013


Sign in to add a comment
 
Reported by gu...@usj.edu.mo, Jun 2, 2011
Morning!

I receive wrong data in the end and start properties of the fullcalendar events after creating a bunch of events (because repeated) in the select callback. For all the events created at different dates, the end and start dates are filled with the startDate and endDate given to the callback function. And strangely, the own fullcalendar _end and _start are correct.

Here is the code:

select: function(startDate, endDate, allDay) {
        if (allDay == false)
        {
          var answer = null;
          // check if we have a start date and end date
          if ("<?php echo $hasDates ?>" == true)
          {
            var answer = confirm('Repeat every week until <?php echo $section['end_date'] ?>?');
          }
          
          if (answer) {            
            var event_start_date = startDate;
            var event_end_date = endDate;
            var section_end_date = new Date(<?php echo $end_date ?>);
            while (event_start_date <= section_end_date)
            {
              calendar.fullCalendar('renderEvent', {
                title: "",
                start: event_start_date,
                end: event_end_date,
                allDay: allDay,
                color: "<?php echo $eventColor ?>"
              }, false);
              calendar.fullCalendar('unselect');
              
              event_start_date.setDate(event_start_date.getDate()+7);
              event_end_date.setDate(event_end_date.getDate()+7);              
            }            
          }
          else {
            calendar.fullCalendar('renderEvent', {
                title: "",
                start: startDate,
                end: endDate,
                allDay: allDay,
                color: "<?php echo $eventColor ?>"
            }, false);
            calendar.fullCalendar('unselect');
          }
                    
          $.post("<?php echo url_for('@section_update_schedule?id=' .$section['id']) ?>", { events: JSON.stringify(calendar.fullCalendar('clientEvents')) }, function(data) {
            calendar.fullCalendar( 'refetchEvents' );
          }, 'json');          
        }
      },

So obviously it is not working when I have the confirm asking for repeating the event and the answer is OK where the 'while' is executed.

I think it's a bug because while start and end are not correct (when returning all the events with the 'clientEvents' method), the internal _start and _end are them correct.

In my case I've solved the issue by replacing start with _start and end with _end in my php script that update the database, but I think it could be nice to solve the problem.

Cheers,
Guill
Jun 3, 2011
Project Member #1 althaus.it
I'm pretty sure that this is a problem of your code and not a bug of FC. The select callback just gets called with the start and end date of the selection. Nothing else.
Status: Reproducing
Jun 3, 2011
#2 gu...@usj.edu.mo
Hi!

Thanks for the answer.
Like said I've solved the pb on my side with a php script, but I've tried again simplifying the javascript code. 
I'm gonna copy/paste the code, and show you what I have from the console log. If you can point what you think it's wrong, would be glad to learn some more javascript today ahah! Else, still might be a fullcalendar issue.

Here's the code:

select: function(startDate, endDate, allDay) {
        var event_start_date = startDate;
        var event_end_date = endDate;
        // get the end date from the section from the database
        var section_end_date = new Date(<?php echo $end_date ?>);
        // but for calculation, we need to add another day (for example if end date is 26/08, needs to make the check against 27/08 at 0am)
        section_end_date.setDate(section_end_date.getDate()+1);
        
        while (event_start_date <= section_end_date)
        {
          calendar.fullCalendar('renderEvent', {
            title: "",
            start: event_start_date,
            end: event_end_date,
            allDay: allDay,
            color: "<?php echo $eventColor ?>"
          }, false);
          calendar.fullCalendar('unselect');
          
          event_start_date.setDate(event_start_date.getDate()+7);
          event_end_date.setDate(event_end_date.getDate()+7);              
        }         
        console.log(calendar.fullCalendar('clientEvents'));        
      },

And see the file for the output I have in the console.
Developer Tools - http___ums.localhost_backend_dev.php_section_1142_profile-1.jpg
140 KB   View   Download
Jun 3, 2011
#3 gu...@usj.edu.mo
The thing is that the internal _end and _start date are obligatory coming from my end and start properties, so still wondering how I can get this wrong? (reference issue?)
May 3, 2012
#4 sionmorr...@gmail.com
Try making a new date every time e.g.:

event_start_date.setDate(event_start_date.getDate()+7);
var copied_event_start_date = new Date(event_start_date.getTime());

Use the 'copied_event_start_date' in 'calendar.fullCalendar('renderEvent',...)'
Aug 13, 2013
Project Member #5 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Invalid
Labels: Type-Bug
Sign in to add a comment

Powered by Google Project Hosting