[Seaside] Trigger a method from javascript
Paul DeBruicker
pdebruic at gmail.com
Sat Jun 30 02:51:54 UTC 2018
using a combination of JQueryInstance>>#on:do: & JQAjax>>#callback:value:
can probably do what you want. See the jQuery docs for how on() works and
what it can return if you haven't .
https://api.jquery.com/on/
e.g.
.
html document
addLoadScript:
(html jQuery expression:'body')
on: #('myEvent')
do:((html jQuery ajax
callback:[:val | self handleJSEvent:val]
value:('return event' asFunction: #('event'));
onSuccess: (self renderViewChangesOn: html))
and then your method to get changed data back to the DOM from that could be
renderViewChangesOn: html
^ html jQuery ajax script:[:s | s << self myScriptToUpdateTheDOM: s]
and the #value: portion above can just be a reference to a js variable in
the DOM if you replace it with
(JSStream on: 'myVariable')
Hope this helps
Pierre Durand wrote
> Hi
>
> I have a nice UI using Pharo/Seaside ans I’m able to control the program
> flow with AJAX callbacks on the UI but only when there are user actions.
> The are some asynchronous processes in javascript (server connexion, file
> downloads) and I would like to trigger some methods in the pharo code when
> they complete.
> What are the options ? Do i have to trigger some event ? How do I
> read/listen to them ?
>
> Thanks !
>
> Pierre
>
> _______________________________________________
> seaside mailing list
> seaside at .squeakfoundation
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
--
Sent from: http://forum.world.st/Seaside-General-f86180.html
More information about the seaside
mailing list