[Seaside] Checkbox and AJAX?

Mariano Martinez Peck marianopeck at gmail.com
Tue Dec 24 15:06:54 UTC 2013

On Mon, Dec 23, 2013 at 12:27 PM, Johan Brichau <johan at inceptive.be> wrote:

> 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?

I was replacing a div which is a container of the table.

> 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.
Ok, I will try that.

> > 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?

Yes. I just need to re-render it so that since it is selected now, it has a
different css.

> 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.
ahaaaa, good point!

> This is what I would try:
>  onClick:  (((JSStream on: 'var myself = this'),
>                 (html jQuery ajax
>                           serializeThisWithHidden;
>                           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...
mmmm this is what get's generated:

function(){var myself =

I don't see 'myself' used it later....

BTW, in your example you do: "html: self report". but...since in this case
I am re-rendering the row only (and not the whole table/report), I should
only re-render the row right?   so I should do something like instead:

self renderRowOfObject: anObject with: html   ?

and there write the row

Thanks for you help Johan.

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20131224/34a1522a/attachment.htm

More information about the seaside mailing list