<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
I'm not sure what precise goal is here, but this seems to select the
row when the checkbox is clicked. What else was required?<br>
<br>
<font face="Georgia">testRender1: html<br>
<br>
| isSel someData selections setSel ss |<br>
<br>
selections _ Set new.<br>
someData _ #('hello' 'goodbye' 'what?').<br>
isSel _ [ :obj | selections includes: obj].<br>
setSel _ [ :obj :val | val ifTrue: [selections add: obj]
ifFalse: [selections remove: obj]].<br>
html table with: [<br>
someData do: [ :e |<br>
html tableRow with: [<br>
html tableData: e.<br>
html tableData: e sorted.<br>
html tableData with: [<br>
html form: [<br>
html label:[ <br>
ss _ (html jQuery this closest: 'tr')
addClass: 'selectedRow'.<br>
html checkbox<br>
onClick: (html jQuery ajax
serializeThisWithHidden);<br>
onClick: (ss);<br>
value: (isSel value: e);<br>
callback: [ :value | setSel value:
e value: value ]<br>
]<br>
].<br>
].<br>
].<br>
].<br>
].<br>
<br>
<br>
</font><br>
<div class="moz-cite-prefix">On 7/8/14 9:06 AM, Mariano Martinez
Peck wrote:<br>
</div>
<blockquote
cite="mid:CAA+-=mX1zZSV+htDZ2turFneV1k6yYxtw1+y01JD-N1-+n_iVw@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Jul 7, 2014 at 6:02 PM, Johan
Brichau <span dir="ltr"><<a moz-do-not-send="true"
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
Mariano,<br>
<br>
Unfortunately, the trick with capturing 'this' for later
use is not going to work. The generated script (or the
onSuccess callback) are not executed in the same scope as
where you defined 'myself'.<br>
</blockquote>
<div><br>
</div>
<div>Ok, I imagined that something like that could happen. </div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">I made
that mistake in this thread earlier on, but I was just not
thinking right. Sorry about that.<br>
<br>
</blockquote>
<div><br>
</div>
<div>Np, it was a good try to avoid having an id for every
row ;)</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
The problem with the apply: is that the apply statement is
added inside the function. I noticed that problem with
JSFunction objects before but I don't know yet if it can
be solved. It does act counter-intuitive though.<br>
<br>
</blockquote>
<div><br>
</div>
<div>Indeed.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Working with an id per row is the easiest solution here, I
think.<br>
<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote>
<div><br>
</div>
<div>OK, perfect. </div>
<div><br>
</div>
<div>Thank you very much guys, </div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">
Johan<br>
</font></span>
<div class="HOEnZb">
<div class="h5"><br>
On 07 Jul 2014, at 15:42, Mariano Martinez Peck <<a
moz-do-not-send="true"
href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>>
wrote:<br>
<br>
> 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:<br>
><br>
> html form: [<br>
> html label:[<br>
> html checkbox<br>
> onClick:
(((JSStream on: 'var myself = this'),<br>
>
(html jQuery ajax<br>
>
serializeThisWithHidden;<br>
>
script: [ :s | s << (((s jQuery
expression:(JSStream on: 'myself')) closest: 'tr')
addClass: 'selectedRow') ])) asFunction apply: #());<br>
> value: (self
isSelected: anObject);<br>
> callback: [ :value
| self selectRow: anObject value: value ]]]<br>
><br>
> But I get: SyntaxError: function statement
requires a name<br>
><br>
><br>
> The onClick is being generated like this:<br>
><br>
> 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>
><br>
> Note that if I put a halt in #script, it doesn't
even get call.<br>
><br>
> I removed the asFunction apply: letting only
something like this:<br>
><br>
> onClick: (((JSStream on: 'var myself = this'),<br>
> (html jQuery ajax<br>
>
serializeThisWithHidden;<br>
> script: [ :s | self
halt. s << (((s jQuery expression:(JSStream on:
'myself')) closest: 'tr') addClass: 'selectedRow') ]))
);<br>
><br>
> 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:<br>
><br>
> a JSScript
($(myself).closest("tr").addClass("selectedRow"))<br>
><br>
> Any ideas?<br>
><br>
> Thanks in advance,<br>
><br>
><br>
><br>
><br>
><br>
> On Sun, Jul 6, 2014 at 9:14 AM, Johan Brichau
<<a moz-do-not-send="true"
href="mailto:johan@inceptive.be">johan@inceptive.be</a>>
wrote:<br>
> 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>
> Johan<br>
><br>
> On 06 Jul 2014, at 01:06, carlo.t <<a
moz-do-not-send="true"
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
moz-do-not-send="true"
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 moz-do-not-send="true"
href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
> > <a moz-do-not-send="true"
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 moz-do-not-send="true"
href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
> <a moz-do-not-send="true"
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>
> Mariano<br>
> <a moz-do-not-send="true"
href="http://marianopeck.wordpress.com"
target="_blank">http://marianopeck.wordpress.com</a><br>
> _______________________________________________<br>
> seaside mailing list<br>
> <a moz-do-not-send="true"
href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
> <a moz-do-not-send="true"
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 moz-do-not-send="true"
href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
<a moz-do-not-send="true"
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 moz-do-not-send="true"
href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
seaside mailing list
<a class="moz-txt-link-abbreviated" href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a>
<a class="moz-txt-link-freetext" href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a>
</pre>
</blockquote>
<br>
</body>
</html>