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