[Seaside] [Q] auto - refresh and live update

Danie Roux droux at tuks.co.za
Sat May 7 01:26:59 CEST 2005


On Fri, May 06, 2005 at 11:03:43PM +0200, Brent Pinkney wrote:
> Hi,
> 
> Is it possible to have portion of a web page automaticaly refresh itself
> after n seconds without reloading the entire page ?

Brent,

This is how I've done it. Drastically condensed, hoping that I'm still
keeping the meaning intact :)

renderContentOn: html 
	html divNamed: 'live_update'
		with: [
			" Create uri for the live action "
			uri _ html urlForLiveRequest: [:t :h | 
					h divNamed: 'live_update' with: [
						 " live action should occur in here, writing to h " 
					].
				].
			" Start of automatic updates "
			html script: 'timedUpdate(', uri asString printString ,')'.
		].

and then this helper JavaScript function:

script
	^'
// This takes a uriFunc creator, creates the function and executes it.
function timedUpdate(uriFunc) {
	var updater = liveUpdaterUri(uriFunc);
	updater();
	var again = "timedUpdate(\""+uriFunc+"\")";
	setTimeout(again, 2000);
}
.

Adjust the parameter to setTimeout to set the frequency.

-- 
Danie Roux *shuffle* Adore Unix




More information about the Seaside mailing list