JQuery FullCalendar trouble with invoking rerenderEvents from ajax success

For some reason, I cannot get the calendar to rerender after a POST. All goes well up to that point:

$('#calendar').fullCalendar({
    ...
    select: function (startDate, endDate) {
        $.ajax({
            url: 'data.php',
            type: "POST",
            data: {
                'start':startDate,
                'end':endDate,
                }
            success: $('#calendar').fullCalendar('rerenderEvents')
            }
     ...
    });

The data posts successfully, my php script adds the new event to the database just fine. The only problem is that the calendar is not being rerendered with the new data in the database.

If I refresh the page (F5 in Firefox) the new event is rendered. Obviously, I need the event to show up as soon as it has been committed to the database. I can't expect my user to refresh the page.

I have done many permutations of this success statment, eg:

function () {
    $('#calendar').fullCalendar('rerenderEvents');
}

and (with my php returning 'success'),

function (data) {
    if (data === 'success') $('#calendar').fullCalendar('renderEvents');
}

However, no matter what, the new event added to the database only shows up if I refresh the screen. Can anyone suggest what I might be doing wrong?

Answers


Try:

$('#calendar').fullCalendar("refetchEvents");

Update 2013-01-31.

That works because you are forcing FC to reread the event source and render the calendar again.

However, if that is sometimes a brute force solution, another way to achieve the same (when possible) is to do this, say in dayClick when creating a new event:

  • update event-DB using $.ajax
  • create the corresponding new event: yourcal.fullCalendar('renderEvent', {id:x,start:timest,end:timend,title:txt}, true);

Need Your Help

When testing with rspec, where to put common “test utility methods”?

ruby-on-rails ruby-on-rails-3 unit-testing rspec

Suppose you have a shopping site that sells widgets. However, the inventory of each widget is limited, so it's important to keep the "widget.number_still_available" number up to date.

Sending message on wso2 socket, getting exception

java wso2 wso2esb wso2carbon

I am trying to send a message over TCP in wso2 framework. I am getting this exception in log:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.