<div dir="ltr">Thank you all for the explanations. I do get it now. Now that I made the simplest case to work (adding an id per tr), I would like to make the Johan solution (finding the closest tr). I tried:<div><br></div>
<div><div><span class="" style="white-space:pre">        </span>html form: [</div><div><span class="" style="white-space:pre">                </span>html label:[<span class="" style="white-space:pre">        </span></div><div><span class="" style="white-space:pre">                        </span>html checkbox</div>
<div><span class="" style="white-space:pre">                                </span> onClick: (((JSStream on: 'var myself = this'),</div><div><span class="" style="white-space:pre">                                </span> (html jQuery ajax</div><div><span class="" style="white-space:pre">                                </span> serializeThisWithHidden;</div>
<div><span class="" style="white-space:pre">                                </span> script: [ :s | s << (((s jQuery expression:(JSStream on: 'myself')) closest: 'tr') addClass: 'selectedRow') ])) asFunction apply: #());</div>
<div><span class="" style="white-space:pre">                                </span>value: (self isSelected: anObject);</div><div><span class="" style="white-space:pre">                                </span>callback: [ :value | self selectRow: anObject value: value ]]]</div></div>
<div><br></div><div>But I get: SyntaxError: function statement requires a name</div><div><br></div><div><br></div><div>The onClick is being generated like this:</div><div><br></div><div>a JSFunction (function(){var myself = this;$.ajax({"url":"/reps","data":["_s=nHl8jzTmLkMbcOME","_k=2IH4kmR1ds-rEaua","accessMenu=Clients","activityMenu=Clients","65",$(this).next("input:hidden").andSelf().serialize()].join("&"),"dataType":"script"})}())<br>
</div><div><br></div><div>Note that if I put a halt in #script, it doesn't even get call.</div><div><br></div><div>I removed the asFunction apply: letting only something like this:</div><div><br></div><div><div> onClick: (((JSStream on: 'var myself = this'),</div>
<div> (html jQuery ajax</div><div> serializeThisWithHidden;</div><div> script: [ :s | self halt. s << (((s jQuery expression:(JSStream on: 'myself')) closest: 'tr') addClass: 'selectedRow') ])) );</div>
</div><div><br></div><div>This solved that problem, but my row doesn't get the css class yet. The #script: does halts, and generates a script like this one:</div><div><br></div><div>a JSScript ($(myself).closest("tr").addClass("selectedRow"))<br>
</div><div><br></div><div>Any ideas?</div><div><br></div><div>Thanks in advance, </div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jul 6, 2014 at 9:14 AM, Johan Brichau <span dir="ltr"><<a href="mailto:johan@inceptive.be" target="_blank">johan@inceptive.be</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Both in the context of the #script: ajax callback-to-smalltalk and the ajax #onSuccess: javascript-callback option, the javascript's this variable will not hold anything related to the DOM.<br>
<br>
The difference between #script: and #onSuccess: is that the former defines a script rendering callback to be executed in Seaside and the latter is a jQuery ajax option to define a javascript callback (to be executed client-side) when the ajax call finishes successfully.<br>
<br>
The onSuccess parameter will accept both a string or a JSScript instance as a Javascript to be executed<br>
In a #script callback, the block argument is a JSScript instance already. The script concatenation operator '<<' expects another JSScript instance (e.g. a JSStream instance). If you concatenate a Smalltalk string with a JSScript instance, the Smalltalk string is serialized as a Javascript string on the JSScript instance.<br>
<br>
cheers<br>
<span class="HOEnZb"><font color="#888888">Johan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 06 Jul 2014, at 01:06, carlo.t <<a href="mailto:snoobabk@yahoo.ie">snoobabk@yahoo.ie</a>> wrote:<br>
<br>
> Hi<br>
><br>
> I thick #script: does not work because this is a separate ajax call where<br>
> the reference to 'this' is not known and is not the row you expect.<br>
> #script would work if you reference a valid DOM id for the row e.g.<br>
> html checkbox<br>
> onClick: (html jQuery ajax serializeThisWithHidden;<br>
> script: [:s | s<br>
> << (s jQuery: #idForRow) addClass: 'selectedRow']);<br>
><br>
> #onSuccess is probably triggering a callback where the reference to 'this'<br>
> is valid and so the following line will work:<br>
> (html jQuery this closest: 'tr') addClass: 'selectedRow'<br>
><br>
> I'm a javascript newbie too but thats what I think is going on.<br>
><br>
> Cheers<br>
> Carlo<br>
><br>
><br>
><br>
><br>
> --<br>
> View this message in context: <a href="http://forum.world.st/Checkbox-and-AJAX-tp4731692p4766717.html" target="_blank">http://forum.world.st/Checkbox-and-AJAX-tp4731692p4766717.html</a><br>
> Sent from the Seaside General mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> seaside mailing list<br>
> <a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
> <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
</div>