[Seaside] Get the result of JS function

Johan Brichau johan at inceptive.be
Tue Sep 22 07:13:44 UTC 2015


Thomas,

You can use the jQuery binding in Seaside to easily return javascript values in ajax callbacks.
For example:

html
	button;
	onClick: (html jQuery ajax callback: [:value | Transcript show: value ] value: (html javascript call: ‘test’ withArguments: #()))
	with: ‘Call test’

The #callback:value: method passes the result of client-side expression to the server-side callback.
Mind that (as the method comment states), this only works for single literal Javascript object (String, Number, Boolean). If you want to pass more complex result values, you can use #callback:json: or write your own serialization if json serialization is not sufficient either.

Hope this answers your question,
Johan

> On 22 Sep 2015, at 07:57, Thomas Heniart <heniart.thomas at gmail.com> wrote:
> 
> Hi everyone,
> 
> Is it possible to get the result after calling a JS function from Seaside
> 
> For exemple I have a function in a JS file with a function test() which return true,
> 
> Can we do something like 
>   result := html aMethod: 'test()'. 
> which execute my function and get the result as a String in result ?
> 
> Cheers,
> Thomas
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list