[Seaside] Checkbox and AJAX?

Johan Brichau johan at inceptive.be
Mon Dec 23 15:27:40 UTC 2013

On 23 Dec 2013, at 14:15, Mariano Martinez Peck <marianopeck at gmail.com> wrote:

> Indeed, it seems I need this because even if I render only the table, the scroll goes up again to the top of the table....

Do you replace the table or only its inner html? In general, to keep the scroll position of an element, you must replace its contents (and not the element itself).
Perhaps in case of a table, you may only re-render the <tbody>, and then also only replacing its inner html.

> So..which other solution you found besides explicit id per row? Of course in the server it is easy to know which row to render, the problem is how to know it in client side. 
> I am would be glad you listen your approaches here.

You want to replace the row where the user clicked in, right?
The $(this) will refer to the checkbox element you clicked, but not anymore in the response script. So, you need to capture it in a lexical scope.

This is what I would try:

 onClick:  (((JSStream on: 'var myself = this'),
 		(html jQuery ajax
                          script: [ :s | s << (((s jQuery expression:(JSStream on: 'myself')) closest: 'tr') html: self report) ])) asFunction apply: #());

The idea is to generate this:

onclick = "(function(){ var myself = this; <<ajax call>> })()"

The above might or might not work because I did not try it. But something along those lines should work...


More information about the seaside mailing list