[Seaside] Generating javascript again ...

Romain Robbes rrobbes at info.unicaen.fr
Wed Jun 2 14:52:22 CEST 2004


Hi again,

	After fiddling a bit with javascript, trying to enhance the 
#autofocus: method, we
have a little suggestion : some scripts should be written at the very 
end of the document.

Example :
this is our enhanced autofocus method, which focuses the element, and
makes the window scroll to it :

autofocus: aBlock
	id := 1000 atRandom.
	html cssId: id.
	aBlock value.
	
	html script:
		     'var o = document.getElementById("', id asString, '");
                         window.scroll(0,o.offsetTop);
                         o.focus();'


This does not work with this version, as the offset of the autofocused 
element
is still 0 when the script is executed. So we had to do some ugly stuff 
such
as storing the script in a variable and writing it later on the stream 
to make the
script work correctly.

Could this be implemented by the framework, with a method such as
delayedScript:, or just script: ?

Note that as said on our previous mail, currently scripts are broken 
since quotes (") are converted to " .
To get around that we had to implement the #script: method :

script: script
	self attributeAt: 'language' put: 'text/javascript'.
	self openTag: 'script'.
	self html: script.
	self closeTag: 'script'.

Previously this called the doesNotUnderstand: method of 
WAAbstractHTMLBuilder,
which writes tags in a default way not suitable for scripts.

	Cheers,
		Cyril Bazin & Romain Robbes



More information about the Seaside mailing list