recurring event refresh

Hi there,

I’m working with recurring events in the scheduler and I have a bit of a “refreshing” problem, so to speak. Here’s the situation:

First of all, I’ve made it so that when a person saves a recurring event, it saves each occurrences physically in the database as a separate event. This part works very well and keeps the data consistent. The problem occurs when a person tries to update a recurring event’s recurrence pattern.

For clarity purposes, I’ve included a screenshot of my lightbox, so in reference to that particular picture, let’s assume someone changes the recurrence number from 3 to 4… it’ll physically insert a new event mirroring the rest of the series. This part works really well and I see the new event appearing on the scheduler.

However, the problem comes when someone changes the value from 4 to three, thus deleting an event in the series. Now, server-side, there’s no problem. The event is indeed deleted from the database, but the problem is that it still shows up on the scheduler. I have this in the init function:

function init() {
		var sections = scheduler.serverList("listeEmployes");
		scheduler.locale.labels.employe_tab = "Employés";
		scheduler.locale.labels.day_tab = "Jour";
		scheduler.locale.labels.week_tab = "Semaine";
		scheduler.locale.labels.month_tab = "Mois";
		scheduler.locale.labels.today_button = "Aujourd'hui";
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		scheduler.config.prevent_cache = true;
		scheduler.config.start_on_monday = false;
		scheduler.config.multi_day = true;
		if (gup('date') == "")
			scheduler.init('scheduler_here',new Date(),"week");
			scheduler.init('scheduler_here',new Date(gup('date').split('-')[0],gup('date').split('-')[1] - 1,gup('date').split('-')[2]),"employe");
		scheduler.load("calendrierConnecteur.php", function(){
			if (gup('id') != "")
		var dp = new dataProcessor("calendrierConnecteur.php");
		dp.attachEvent("onAfterUpdateFinish", function(sid, action, tid)
			return true;

As you can see, I’ve put a “scheduler.load” statement in the “onAfterUpdateFinish” event of the dataprocessor, but it does absolutely nothing. I’ve also tried the “onAfterUpdate” event and it’s the same. So, where do I put the refresh statement so that the deleted event will disappear correctly?

Thanks in advance,



  1. Please verify that your handler for ‘onAfterUpdateFinish’ event is correctly called (by placing debug point for example).
  2. If you are loading all events again then try using clearAll() before load.

Best regards,

The event (whether onAfterUpdate or onAfterUpdateFinish) is indeed executed properly, I’ve verified it with firebug. I think what’s going on is that the scheduler.load() function reloads only the events present into the database without checking whether the events appearing on the scheduler actually exists or not. That’s why, whenever I change my value from 3 to 4, the new event shows up and, when I do the opposite, changing it from 4 to 3, the event becomes dangling and the load function ignores it entirely because it’s not physically in the database.

Using clearAll() has resolved the issue, though I could personally go without the events flickering off and on, but if that’s the only way to go, I think I can manage. Of course, being ever the perfectionist, I’m going to have to ask yet another question.

function myUpdate($action)
if ($action->get_value("RecId") != "NULL")
				$requete = "SELECT TodoId FROM tblpmtodo WHERE RecId = " . $action->get_value("RecId") . " ORDER BY StartDateTime";
				$resultat = $scheduler->sql->query($requete);
				$repeatArrayStart = explode(";", $action->get_value('repeatArrayStart'));
				$repeatArrayEnd = explode(";", $action->get_value('repeatArrayEnd'));
				$limite = (mysql_num_rows($resultat) > $action->get_value('repeatArrayCount')) ? mysql_num_rows($resultat) : $action->get_value('repeatArrayCount');
				$i = 0;
				while ($i < $limite)
					if ($i < $action->get_value('repeatArrayCount') && $i < mysql_num_rows($resultat))
						$ligne = mysql_fetch_array($resultat);
						$requete = "UPDATE tblpmtodo SET " .
							"StartDateTime = \"" . $repeatArrayStart[$i] . "\", " . 
							"EndDateTime = \"" . $repeatArrayEnd[$i] . "\" " . 
							"WHERE TodoId = " . $ligne['TodoId'];
					else if ($i < $action->get_value('repeatArrayCount') && $i >= mysql_num_rows($resultat))
						$etiquette = explode("-", $action->get_value('Etiquette'));
						$requete = "INSERT INTO tblpmtodo (Etiquette, StartDateTime, EndDateTime, StatutId, PrcComplete, RecPattern, RecId, FinRec) VALUES (\"" . 
						mysql_real_escape_string($action->get_value('Etiquette')) . "\", \"" . 
						$repeatArrayStart[$i] . "\", \"" . 
						$repeatArrayEnd[$i] . "\", 1, 0, \"" . 
						$action->get_value('RecPattern') . "\", " . 
						$action->get_value('RecId') . ", \"" . 
						$action->get_value('FinRec') . "\")";
						mysql_query($requete) or die (mysql_error());
						$scheduler->sql->query("UPDATE tblpmtodo SET Etiquette = \"" . $etiquette[0] . "-" . $etiquette[1] . "- " . mysql_insert_id() . 
												"\" WHERE TodoId = " . mysql_insert_id());
					else if ($i >= $action->get_value('repeatArrayCount') && $i < mysql_num_rows($resultat))
						$ligne = mysql_fetch_array($resultat);
						$scheduler->sql->query("DELETE FROM tblpmtodo WHERE TodoId = " . $ligne['TodoId']);
						$scheduler->sql->query("DELETE FROM tblpmdestinatairespermissions WHERE TodoId = " . $ligne['TodoId']);
						$scheduler->sql->query("DELETE FROM tblpmrappel WHERE TodoId = " . $ligne['TodoId']);
$scheduler->event->attach("beforeUpdate", "myUpdate");

This is part of the server-side code I use to update my recurring events. As you can see, I’m using:


to delete/update my recurring events and it works perfectly. I was just wondering if there was a way, server-side, to give some sort of signal to the client-side scheduler that an event has been deleted. That might actually solve my reloading problems.

Anyway, if there are no way of doing things, I’ll content myself with using clearAll(), but my sense of perfection demands that I ask, so there :wink:.

Thanks for the earlier answer and keep up the good work :slight_smile:.


Using clearAll() has resolved the issue, though I could personally go without the events flickering off and on

You can alter existing code and add clearAll call as first line of scheduler.on_load event. In such case clearing old events and rendering new onew will be done as single operation, without flickering.

I was just wondering if there was a way, server-side, to give some sort of signal
Place where it necessary
$action->set_response_attribute(“wasdeleted”, “id here”);

and on client side

dp.attachEvent("onAfterUpdate", function(sid, action, tid, tag){ var info = tag.getAttribute("wasdeleted"); if (info) do_something(); return true; });

Thanks for your solution, I didn’t add the clearAll in the on_load event of the scheduler, but went instead with your second solution. When I actually have to delete multiple events at once, server-side, I create a list of those ID which I dump into a custom attribute like this:

$action->set_response_attribute("deletedEvents", "ID1;ID2;ID3");

Then, client-side on the onAfterUpdate event, I recover the deletedEvents attribute and loop through the list, calling the deleteEvent of the scheduler like this:

dp.attachEvent("onAfterUpdate", function(sid, action, tid, tag)
			if (tag.getAttribute("deletedEvents") != null)
				var info = tag.getAttribute("deletedEvents").split(";");
				for (var i = 0; i < info.length; i++)
					if (info[i] != tid) 
			return true;

That solved my flickering problem. Thanks a lot for your suggestion Stanislav :slight_smile:.