[Seaside] Javascript rendering and dynamically bound variables

Sebastian Sastre ssastre at seaswork.com
Tue May 26 17:15:57 UTC 2009


>Can you come up with other alternatives? 
> Which approach
> do you prefer over the other and why?
> 
>
Hi Mariano, 
I don't know if this helps you but I've also faced that need and not having the
canvas at the time.
I've solved it by making script renderers which are blocks that returns a
rendered script when you eval them with a canvas. 
Instead of rendering directly, this family of components can preset arbitrary
script renderers that will be rendered when appropiate and have their arbitrary
javascript.

Simplifying my real framework, the basic render is something like:

renderContentOn: html

	html div
		id: self id; "every component has a unique id"
		with: [self renderPresenterContentOn: html]; "I call presenters
this kind of seaside components"
		yourself.

	html script: (self renderScriptsOn: html) 

and a simplified version of:

renderScriptsOn: html

	"not all presenters inject javascript only those 
	who needs the homologue dom element initialized 
	with some functions and js stuff"
	self hasToInitializeHomologue ifTrue:[ 
		html script with: (self renderAllScriptsOn: html)]

		
the custom rendering of the componet for this family happens inside
#renderPresenterContentOn:
cheers,
sebastian



More information about the seaside mailing list