[Seaside] Re: refreshing events on JQFullCalendar

Paul DeBruicker pdebruic at gmail.com
Wed Jan 16 00:56:15 UTC 2013

Hi Davide,

It would help me to run this discussion through the Seaside list.  So
I've cc'd it.

answers below.

On 01/15/2013 11:51 AM, Davide Varvello wrote:
> Hi Paul
> On Tue, Jan 15, 2013 at 7:48 PM, Paul DeBruicker <pdebruic at gmail.com
> <mailto:pdebruic at gmail.com>> wrote:
>     Hi Davide,
>     I don't know.  It looks like you could instead return a json array of
>     events and run the renderEvent method on each of them.  See
>     http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/
>     I don't know if that means you'll end up with two duplicated events of
>     different color or not.
>     Or use #updateEvent:
>     (http://arshaw.com/fullcalendar/docs/event_data/updateEvent/) method
>     after using some jQuery to find the changed events in the client and set
>     their new CSS properties.  Have your callback make a Dictionary with the
>     keys the id of each modified event and the values the revised CSS rules.
>      then emit that as json and iterate over it on the client finding the
>     EventObject and change its CSS.
> Yes, but It's not easy to me to find the event.
> Do you have any reference on jQuery ajax and seaside? (I already have
> the seaside book, but there are very few examples)
> Cheers
>  Davide

Nothing other than the jQuery docs. jQuery in Seaside maps 1:1 with
jQuery because I think Lukas Renggli builds the package from the jQuery
docs or source.  I'm sure someone on the Seaside list has a better
answer for you about jQuery + ajax + Seaside.  I don't think its
possible to do conditional logic with it either.  My preference, and I
think the recommendation, is to do as little as possible in Seaside with
jQuery and instead put most of the logic in a js method that is called
on the client.

The docs of fullcalendar here: http://arshaw.com/fullcalendar/docs
are extensive.  I think I've got most of it in that package.  To get the
events in the client you want #clientEvents:

I added a link to the example that does what you want, in a limited way.
 Every 10 seconds it changes the background color of the events and only
sends enough JSON to identify the event and specify the new background
color.  It does not re-render the whole thing.  I think building the js
function in Seaside would be not fun.

When you initially render the events be sure to give them a unique id by
setting something in the id inst var. (In the example its the first line
in the #renderCalendar: method)

Take care


>     Seems like there are mechanisms there to only update specific events but
>     I haven't done it before.
>     Good luck and sorry I can't be more help
>     Paul
>     On 01/15/2013 10:28 AM, Davide Varvello wrote:
>     > Hi Paul,
>     >
>     > I have another question on JQFC.
>     >
>     > I'm trying to refresh events periodically, they should change their
>     > background color when some condition shows.
>     >
>     > I'm adding to your JQFullCalendarExampleCalendar this bit of code:
>     >
>     > html script: (  ( (html jQuery ajax) callback: [ :ignored | self
>     > changeEventColor ] json: '';
>     >  script: [ :s | s << (s jQuery id: 'calendar') replaceWith: [ :h |
>     self
>     > renderCalendar: h ] ]) interval: 10 seconds ).
>     >
>     > As you can see, every ten seconds I poll the server and send the
>     message
>     > changeEventColor that controls the condition and change the color
>     of my
>     > events.
>     > But, unfortunately, to update the color of events I find nothing else
>     > than refreshing the entire calendar (self renderCalendar: h).
>     > Is there a way to repaint single events?
>     >
>     > TIA
>     >  Davide

More information about the seaside mailing list