[Seaside] how to use #replaceWith:

Johan Brichau johan at inceptive.be
Sat Sep 18 14:27:39 UTC 2010


The script you pass on to onClick has many strange things. It seems you are trying to render a script as an ajax response. 
Seaside (and jQuery) have exactly what you need. Here's what you are probably trying to do:

onClick: ((html jQuery ajax script:[:s | s << ((s jQuery id: #bob002) replaceWith: [:h | h div with: Time now asString])]);

The above will attach a handler script to the onClick event, that loads and executes a script that replaces the second div with a new div.
However, you probably only want the internals of the div to be replaced. This script does exactly that:

onClick: ((html jQuery id: #bob002) load html: [:h | h render: Time now asString]);

The above will attach a handler script to the onClick event, that does an ajax html load to replace the contents of the second div with the time at which the click happened.

On 18 Sep 2010, at 15:19, Bob Arning wrote:

> Hi,
> 
> I'm trying to figure out how to use #replaceWith:. After many permutations, still no-go. :-(
> 
> I want to render 2 divs. When the first is clicked, I want to replace the second with something else. Any suggestions?
> 
> renderContentOn: html
> 
>     html div
>         style: 'height: 44px; width: 65px; background-color: red;';
>         id: 'bob001';
>         onClick: (html jQuery ajax html: [ :h |
>             h render: ((h jQuery id: #bob002) replaceWith: Time now asString).
>         ]);
>         with: [html text: 'bob001'].
>     html div
>         style: 'height: 44px; width: 65px; background-color: green;';
>         id: 'bob002';
>         with: [html text: 'bob002'].
>         
> TIA,
> Bob
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100918/09375fc2/attachment.htm


More information about the seaside mailing list