I've two person that they have acces to FullCalendar application in the same time but from different computer , they would see t开发者_运维百科he updates of appointments of the other without pressing refresh button , I've tried with RefetchEvents but nothing.Do you have any suggest. Many thanks
refetchEvents
should get the events from all sources and rerender them, so I'm curious what is failing. Also, when there are changes how are they being pushed to your server? Or are the changes staying on the client only? You need to make sure you are saving the events from each client to the server so that the other client can get them. You can check if you are currently storing new events on the client side with the clientEvents call to FullCalendar. See what it returns to you. If so, make sure that when an event is added via select
or whatever other method you are using to add events that you are saving it to the server.
You can poll for it on a regular basis. Set up a Javascript setInterval
that calls refetchEvents
on a regular basis. The downside of this approach is that it will continuously repaint the events. You can also poll the server for just a timestamp that your database or other source containing the events was updated and only call refetchEvents
on update. If you are using a server that supports it you can also consider using comet to push information from your server.
If I was doing some sort of poll, here's what I would try:
// set this before calling the calendar
var timeLastUpdated = new Date().getTime();
function pollForNewEvents() {
var url = "/path/to/server/check";
$.get(url, {"timeLastUpdated": timeLastUpdated}, function(data) {
data = parseInt(data, 10); // assume data is milliseconds since epoch
if(data > timeLastUpdated) {
$("#calendar").fullCalendar('refetchEvents')
timeLastUpdated = data;
}
});
}
setInterval("pollForNewEvents()", 10000);
精彩评论