[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 =
this;jQuery.ajax({"url":"/MyApp","data":["_s=w9GmvDOQpAp_pp0c","_k=-3MfxH3kyGWxn6Vi","96",jQuery(this).next("input:hidden").andSelf().serialize()].join("&"),"dataType":"script"})}()

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.


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



-- 
Mariano
http://marianopeck.wordpress.com
-------------- 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