[Seaside] Checkbox and AJAX?

Mariano Martinez Peck marianopeck at gmail.com
Mon Dec 23 13:15:29 UTC 2013


On Fri, Dec 20, 2013 at 6:49 PM, Johan Brichau <johan at inceptive.be> wrote:

> Mariano,
>
> You can combine a script callback with the ajax callback that performs the
> serialization of the checkbox.
> In that script callback, you can generate a script that replaces the
> contents of the tableContainer (having an id, for example).
>
>         html form: [
>                 html label:[
>                         html checkbox
>                                 value: (self isSelected: anObject);
>                                 onClick: (html jQuery ajax
>                                         serializeThisWithHidden;
>                                         script: [ :s | s << ((s jQuery id:
> id) html: self report) ]);
>                                 callback: [ :value | self selectRow:
> anObject value: value ]]]
>
> What happens is the following:
> - The ajax callback first executes the serialization of the checkbox. This
> is the callback you attached to your checkbox itself
> - The script callback of the ajax request generates the response of the
> ajax callback and thus is executed last
> - The generated script gets executed on your client. It replaces the
> contents of the tableContainer with what 'self report' rendered.
>
> There's quite some gotcha's in the above:
> - you can combine multiple callbacks on a single ajax request, but only
> one 'response' callback can exist, otherwise you need to resort to chaining
> using the onComplete: method of an ajax request.
> - if you would use method temporaries to pass values from one callback
> block to another, you need to use a value holder object in GemStone [1]
> (even in 3.1 !)
>
>
Thanks Johan for all the explanation. It is much clear now. And moreover,
it worked nicely! Thanks!

Replacing only the row is not a problem either. You just need to know which
> row to replace both server-side and client-side. Generating explicit ids
> per row is a possibility, but there are more.
>
>
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....
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.

Thanks!



> cheers
> Johan
>
> [1]
> http://forum.world.st/use-of-method-temporaries-in-callback-blocks-td2340788.html
>
>
> On 20 Dec 2013, at 22:15, Mariano Martinez Peck <marianopeck at gmail.com>
> wrote:
>
> > Now, a last question. In my case, I want to re-render the whole
> table/containter after the ajax because selected rows have a special color
> (css class)....I know which is the ID of my tableContainer. I also have
> access to the component I would like to re-render (self report). I tried a
> few things like this:
> >
> > renderCellFormContent: anObject on: html
> >
> >       html form: [
> >               html label:[
> >                       html checkbox
> >                               value: (self isSelected: anObject);
> >                               onClick: (html jQuery ajax
> >                                       serializeThisWithHidden;
> >                                       html: [ :renderer | self halt.
> renderer render: self report ]
> >                                       "onSuccess: ((html jQuery:
> '#tableContainer') load)");
> >                               callback: [ :value | self selectRow:
> anObject value: value ]]]
> >
> > But none worked. I am still newbie with Ajax stuff so I am probably
> doing something wrong.
> > BTW, if I can only refresh the row, cool, but as far as I know that's
> not possible (or complex?). So just rendering the table again I think it
> would be ok (unless I loose scroll position).
> _______________________________________________
> 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/20131223/dd1166da/attachment.htm


More information about the seaside mailing list