[Seaside-dev] Rendering on HTML and Script canvas
Esteban A. Maringolo
emaringolo at gmail.com
Fri Apr 6 01:41:51 UTC 2018
On 05/04/2018 02:25, Johan Brichau wrote:
> Hi Esteban,
>
>> On 3 Apr 2018, at 20:08, Esteban A. Maringolo <emaringolo at gmail.com
>> <mailto:emaringolo at gmail.com>> wrote:
>> 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.
> 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?
The above is what I usually do, but lately I switched to use #script:
and a #replaceWith:. Because that way I can handle also callbacks, and
other other things in a single HTTP roundtrip instead of performing a
#callback:/#onSuccess:, also the code is easier to implement. It's
heretic, but I found it to be better.
So, let's say:
html anchor
onClick: ((html jQuery ajax
callback: [self doSomething])
onSuccess: ((html jQuery id: #id)
load html: [:r | self renderOn: r ]))).
Is converted to this:
html anchor
onClick: (html jQuery ajax script: [:s |
self doSomething.
s << ((html jQuery id: #id) replaceWith: [:r |
self renderOn: r ])
]).
Maybe the replaceWith: doesn't trigger the "onLoad" event?
I should write a vanilla example to test the different cases. I'll try
to do it tomorrow.
Regards!
--
Esteban A. Maringolo
More information about the seaside-dev
mailing list