[Seaside] Generating an callback URL for third-party use

Johan Brichau johan at inceptive.be
Wed May 28 06:12:05 UTC 2014

Bob's answer is similar, but I prefer to explicitly use jQuery's on:selector:do: method.

The full documentation is here: http://api.jquery.com/on/

This way of working with delegated events is really necessary if you have hundreds of callbacks to attach. That never scales and your performance will be horrible (large response size, large seaside session, ...)


On 28 May 2014, at 02:25, Esteban A. Maringolo <emaringolo at gmail.com> wrote:

> Additionally to this, is it possible to pass an argument to such callback?
> I'm dealing with a data table on the browser and want to show details
> of the selected item once clicked. Instead of creating hundreds of
> callbacks (one per row), I'd like to pass an identifier of such item
> to the callback, in order to be able to retrieve it from the
> datasource. Is it possible?
> Is there a better way to register a callback that does exactly the same?
> something to replace this:
> collection do: [:each | html anchor callback: [self edit: each]; with: 'Edit' ]
> Into a reutilizable callback with an added parameter.
> I looked into the WAListTag class and it seems there is no other way
> other than creating a single callback per item.
> Maybe it is cheap in terms of memory and I worrying about an non
> existing problem. But there should be other way.
> Regards!
> Esteban A. Maringolo
> 2014-05-27 19:46 GMT-03:00 Esteban A. Maringolo <emaringolo at gmail.com>:
>> I'm struggling to find a clean way of generating an url to be used for
>> external reference from a javascript library/plugin, such as
>> crossfilter or DataTables.
>> E.g the constructor configuration object has a dataUrl parameter,
>> which will be used by the plugin to retrieve the data.
>> $('element').plugin({dataUrl: "..."});
>> I can generate the expression to retrieve it from anywhere, but what I
>> want is to associate an url with a callback that will answer the data
>> requested.
>> Today I'm assigning results to a local variable using a predefined
>> callback function, and then initializing my data dependent function
>> assuming there is going to be data in that variable.
>> Ej:
>> html document addLoadScript: (
>>  ((html jQuery getJson
>>     json: [ :json | self renderItemsOnJson: json ];
>>     onSuccess: (JSStream on: 'myCallbackFunction(arguments[0]);')
>> asFunction) asFunction assignTo: 'loadCrossfilterData')).
>> html document addLoadScript: (JSStream on: 'loadCrossfilterData()').
>> I want some way to create a url callback in the way of:
>> callbackUrl :=  html magicalCallbackRegister: [ :json | self
>> renderItemsOnJson: json ]. "answers a url"
>> JSStream on: '$(''#element'').plugin({dataUrl:"', callbackUrl, '"})'.
>> which once rendered as JS would be:
>> $('#element').plugin({dataUrl:"/app/_s=...&_k=...&n"});
>> I know this must be possible, because Seaside does it for all the
>> callbacks, but I don't know how to create a simple callback and then
>> get it's url to pass it around.
>> I hope all I wrote is intelligible. Otherwise I can rephrase it in
>> other unintelligible way. :)
>> Esteban A. Maringolo
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list