Re: Trigger a method from javascript

Paul DeBruicker <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
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

> [email protected]

> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside





--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.