[Seaside] How to combine serialize and a load.

Lukas Renggli renggli at gmail.com
Sat Jan 30 10:44:46 UTC 2010

>    html select
>            id: html nextId;
>            list: (self session findCodeByParent: 'region' type: 'region');
>            selected: model region;
>            callback: [ :value | self regionSelectionChanged: value ];
>            onChange: (html jQuery ajax  serializeThis);
>                onAjaxComplete: ((html jQuery id: 's_results' ) load html: [:
> r | self renderResultsOn: r]).

1) #onAjaxComplete: is implemented on the jQuery object, not on the
WASelectTag and not on the JQAjax instance. #onAjaxComplete: is used
to register a global completion handler, there is also #onComplete: on
the JQAjax itself that is used to register for that particular
instance only.

2) You create two AJAX requests that are triggered one after each
other. While this generally works it is very inefficient because it
does two roundtrips to the server. If possible you should always
combine AJAX calls. In most cases this is possible.

Try something along:

   .. onChange: ((html jQuery id: 's_results') load
        html: [ :r | self renderResultsOn: r ])

That serializes AND renders the results in one AJAX call. You also
don't need the #onAjaxComplete: because this is just one AJAX call.


Lukas Renggli

More information about the seaside mailing list