[Seaside] SUCondition problem

Lukas Renggli renggli at gmail.com
Mon May 21 18:44:23 UTC 2007

> The following code always shows an alert :
> html scriptaculous script alert: 'test !'; condition: (html evaluator
> callback: [:s | false])

The explanation: The A in AJAX stands for asynchronous. This means the
evaluator will send out the request and immediately return to the
caller without waiting for the response. So your expression

    html evaluator callback: [:s | false]

just returns the evaluator, not the result. In JavaScript anything but
false, null and undefined is true, therefor your alert gets triggered
all the time. The callback will be evaluated later on, but there is
nobody around for the result anymore.

A possible solution: You check the condition on the server and
generate the script from there:

    html evaluator callback: [ :script |
        self isSatisfied
           ifTrue: [ script alert: 'everything ok' ]
           ifFalse: [ script alert: 'ouch, there is something wrong' ] ]

Hope this helps,

Lukas Renggli

More information about the seaside mailing list