[Seaside-dev] Rendering on HTML and Script canvas

Johan Brichau johan at inceptive.be
Thu Apr 5 05:25:10 UTC 2018


Hi Esteban,

> On 3 Apr 2018, at 20:08, Esteban A. Maringolo <emaringolo at gmail.com> wrote:
> 
> I find myself rendering a lot on JSScript instances via AJAX, and in
> some cases the elements I render have to create separate <script> tags
> to initialize or execute something on the client side.
> 
> When doing a full page request we have the addLoadScript: and we can
> pass that script around our object to append whatever we want on top of
> it. But on AJAX we don't have such feature.

If you have a method like this:

renderOn: html
	html addLoadScript: (self someScript)

and you invoke it in an ajax request like this:

(html jQuery id: #id) load html:[:r | self renderOn: r ].

Then the script generated in ‘someScript’ will be executed when the html is loaded on the page.
Seaside adds the loadscripts explicitly to the rendered html as script tags that get executed by jQuery when loaded in an ajax request.

You can also do it ‘manually' like this:

(html jQuery id: #id) load html:[:r | 
	self renderOn: r. 
	r script: self someScript ].

Which is actually the same, just less convenient.

Is this what you are looking for? Can you share an example where it does not work or fit your needs?

cheers!
Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside-dev/attachments/20180405/0ff0012b/attachment.html>


More information about the seaside-dev mailing list