1
votes

I'm using arshaw.com/fullcalendar/ in a Rails application. It's really good!!

I'm using eventDrop to update the events table when the user moves(drags) an event from one day to another. This works fine for dragging events that have start and end times. But, it doesn't update the table when you drag an allday event.

This is my table update code:

  eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) ->
    updateEvent(event);

  eventResize: (event, dayDelta, minuteDelta, revertFunc) ->
    updateEvent(event);


updateEvent = (the_event) ->
  $.update "/events/" + the_event.id,
    event:
      title: the_event.title,
      starts_at: "" + the_event.start,
      ends_at: "" + the_event.end,
      description: the_event.description

Any ideas?

Thanks!

1

1 Answers

0
votes

The simple way I solved this is with little hack (I don't like hacks, but I think this one is needed).

What I do is, upon allDay event creation, I add end time for that event programatically (1h after start), making sure all events always have end time:

select: function (start, end, allDay, jsEvent, view)
    {
        var title = prompt('event title:');

        if (title)
        {
            var allDay = allDay ? true : false;
            if (allDay)
            {   // this ensures that allDay tasks have end time if they're to be changed to non allDay tasks
                end.setHours(end.getHours() + 1);
            }

            createEvent(
            {
                title: title,
                start: start,
                end: end,
                allDay: allDay
            });
        }
        $calendar.fullCalendar('unselect');
    },

Here's createEvent function:

function createEvent(event)
{
    $spinner.show();
    $.create(
        "/tasks",
        {
            "task":
            {
                name: event.title,
                starts_at: "" + event.start,
                ends_at: "" + event.end,
                all_day: event.allDay
            }
        },
        function (response)
        {
            $spinner.hide();
            var id = response.id;
            $calendar.fullCalendar('renderEvent',
            {
                id: id,
                title: event.title,
                start: event.start,
                end: event.end,
                allDay: event.allDay ? true : false
            },
            true // make the event "stick"
            );
        }
    );
}