Javascript questions Re: [Seaside] Textarea and setSelectionRange()

Lukas Renggli renggli at gmail.com
Tue Mar 17 19:59:00 UTC 2009


> Okay.  Thanks, but isn't it fair to ask what should be Seaside idioms or
> best practices for using Javascript?

Sure, but as I said it mostly depends on the Javascript libraries you are using.

With Scriptaculous (http://www.prototypejs.org/api/event/observe) and
JQuery (http://docs.jquery.com/Events/bind) you have totally different
idioms on how to register for events. In these two cases Seaside does
not try to run its own thing, but instead it just provides a nice
Smalltalk API to the Javascript interface.

In any case you can register for Javascript events directly while
rendering the HTML source using the event selectors defined in
WATagBrush, but that doesn't give much flexibility and certainly no
control over order (see
http://www.quirksmode.org/js/introevents.html).

One thing Seaside provides out of the box is the addition of onLoad
scripts. This can be done by evaluating "html document addLoadScript:"
in Seaside 2.9 and "self session addLoadScript:" in earlier versions.
The code added through these calls is evaluated in order when the page
has completely loaded, but there is no control over other Javascript
code that might be present on your site and that might define other
load handlers.

Cheers,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch


More information about the seaside mailing list