<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jul 5, 2014 at 11:37 AM, Paul DeBruicker <span dir="ltr">&lt;<a href="mailto:pdebruic@gmail.com" target="_blank">pdebruic@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Try changing from #script: to #onSuccess:</blockquote><div><br></div><div>Awesome! that worked. Now, can you explain to a newbie what is the difference please? :)</div>
<div><br></div><div>Thanks, </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
<br>
<br>
<br>
<br>
Mariano Martinez Peck wrote<br>
<div><div class="h5">&gt; Hi,<br>
&gt;<br>
&gt; I am back trying to make this example to work. What I cannot do is to add<br>
&gt; my &quot;selectedRow&quot; css class to the selected TR. I did this:<br>
&gt;<br>
&gt; html form: [<br>
&gt; html label:[<br>
&gt; html checkbox<br>
&gt;  onClick:<br>
&gt;                 (html jQuery ajax<br>
&gt;                           serializeThisWithHidden;<br>
&gt;                           script: [ :s | s &lt;&lt; (&#39;$(&#39;&#39;#tr&#39;, anInteger<br>
&gt; asString, &#39;&#39;&#39;).addClass(&#39;&#39;selectedRow&#39;&#39;);&#39;)<br>
&gt;  ]);<br>
&gt; value: (self isSelected: anObject);<br>
&gt; callback: [ :value | self selectRow: anObject value: value ]]]<br>
&gt;<br>
&gt;<br>
&gt; The callbacks does work, the server gets correct etc...in fact, if I then<br>
&gt; refresh the page, the row is correctly applied the &quot;selected&quot; row. The<br>
&gt; problem is that I cannot make the row selected with the #script:   When I<br>
&gt; debug, the #script:  is something like:<br>
&gt; $(&#39;#tr4&#39;).addClass(&#39;selectedRow&#39;);<br>
&gt;<br>
&gt; But nothing happens. If I go to a JavaScript console in the browser and I<br>
&gt; paste the very same line, it works!<br>
&gt;<br>
&gt; Any ideas what I am doing wrong?<br>
&gt;<br>
&gt; Thanks in advance,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Dec 24, 2013 at 12:06 PM, Mariano Martinez Peck &lt;<br>
<br>
&gt; marianopeck@<br>
<br>
</div></div>&gt;&gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Dec 23, 2013 at 12:27 PM, Johan Brichau &amp;lt;<br>
<br>
&gt; johan@<br>
<br>
&gt; &amp;gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 23 Dec 2013, at 14:15, Mariano Martinez Peck &amp;lt;<br>
<br>
&gt; marianopeck@<br>
<br>
&gt; &amp;gt;<br>
<div class="">&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; Indeed, it seems I need this because even if I render only the table,<br>
&gt;&gt;&gt; the scroll goes up again to the top of the table....<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Do you replace the table or only its inner html?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I was replacing a div which is a container of the table.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; In general, to keep the scroll position of an element, you must replace<br>
&gt;&gt;&gt; its contents (and not the element itself).<br>
&gt;&gt;&gt; Perhaps in case of a table, you may only re-render the<br>
<br>
</div><div><div class="h5">&gt; , and then<br>
&gt;&gt;&gt; also only replacing its inner html.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt; Ok, I will try that.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt;  &gt; So..which other solution you found besides explicit id per row? Of<br>
&gt;&gt;&gt; course in the server it is easy to know which row to render, the problem<br>
&gt;&gt;&gt; is<br>
&gt;&gt;&gt; how to know it in client side.<br>
&gt;&gt;&gt; &gt; I am would be glad you listen your approaches here.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; You want to replace the row where the user clicked in, right?<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Yes. I just need to re-render it so that since it is selected now, it has<br>
&gt;&gt; a different css.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; The $(this) will refer to the checkbox element you clicked, but not<br>
&gt;&gt;&gt; anymore in the response script. So, you need to capture it in a lexical<br>
&gt;&gt;&gt; scope.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt; ahaaaa, good point!<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; This is what I would try:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;  onClick:  (((JSStream on: &#39;var myself = this&#39;),<br>
&gt;&gt;&gt;                 (html jQuery ajax<br>
&gt;&gt;&gt;                           serializeThisWithHidden;<br>
&gt;&gt;&gt;                           script: [ :s | s &lt;&lt; (((s jQuery<br>
&gt;&gt;&gt; expression:(JSStream on: &#39;myself&#39;)) closest: &#39;tr&#39;) html: self report)<br>
&gt;&gt;&gt; ]))<br>
&gt;&gt;&gt; asFunction apply: #());<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The idea is to generate this:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; onclick = &quot;(function(){ var myself = this; &lt;<br>
&gt; &lt;ajax call&gt;<br>
&gt;&gt; })()&quot;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The above might or might not work because I did not try it. But<br>
&gt;&gt;&gt; something<br>
&gt;&gt;&gt; along those lines should work...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt; mmmm this is what get&#39;s generated:<br>
&gt;&gt;<br>
&gt;&gt; function(){var myself =<br>
&gt;&gt; this;jQuery.ajax({&quot;url&quot;:&quot;/MyApp&quot;,&quot;data&quot;:[&quot;_s=w9GmvDOQpAp_pp0c&quot;,&quot;_k=-3MfxH3kyGWxn6Vi&quot;,&quot;96&quot;,jQuery(this).next(&quot;input:hidden&quot;).andSelf().serialize()].join(&quot;&amp;&quot;),&quot;dataType&quot;:&quot;script&quot;})}()<br>

&gt;&gt;<br>
&gt;&gt; I don&#39;t see &#39;myself&#39; used it later....<br>
&gt;&gt;<br>
&gt;&gt; BTW, in your example you do: &quot;html: self report&quot;. but...since in this<br>
&gt;&gt; case<br>
&gt;&gt; I am re-rendering the row only (and not the whole table/report), I should<br>
&gt;&gt; only re-render the row right?   so I should do something like instead:<br>
&gt;&gt;<br>
&gt;&gt; self renderRowOfObject: anObject with: html   ?<br>
&gt;&gt;<br>
&gt;&gt; and there write the row<br>
&gt;&gt;<br>
&gt;&gt; Thanks for you help Johan.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;  Johan_______________________________________________<br>
&gt;&gt;&gt; seaside mailing list<br>
&gt;&gt;&gt;<br>
<br>
</div></div>&gt; seaside@.squeakfoundation<br>
<div class=""><br>
&gt;&gt;&gt; <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Mariano<br>
&gt;&gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Mariano<br>
&gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;<br>
</div>&gt; _______________________________________________<br>
&gt; seaside mailing list<br>
<br>
&gt; seaside@.squeakfoundation<br>
<br>
&gt; <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>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://forum.world.st/Checkbox-and-AJAX-tp4731692p4766672.html" target="_blank">http://forum.world.st/Checkbox-and-AJAX-tp4731692p4766672.html</a><br>
Sent from the Seaside General mailing list archive at Nabble.com.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<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></div>