<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Chris,<div class=""><br class=""></div><div class="">jQuery’s replaceWith accepts either an html string or a javascript function. I believe this is also true for the Seaside binding implementation.</div><div class="">Does the following code not do what you want?</div><div class=""><br class=""></div><div class=""><div dir="ltr" class=""><div class=""><div class="">&nbsp;html script defer with:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((html jQuery id: buttonId) onClick:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(<font color="#38761d" class="">(html jQuery id: replacementId) call: 'replaceWith' with: ajaxRequest&nbsp;</font>asFunction)).</div><div class=""><br class=""></div><div class="">The JSObject&gt;&gt;render: method should always produce a string, as it is called when the object needs to be rendered on a stream. It does not produce a ‘javascript string’.</div><div class="">What you want is to construct a function and give it as an argument to the replaceWith function (see code above). Imho, that should work.</div><div class=""><br class=""></div><div class="">Johan</div></div></div><br class=""><div><blockquote type="cite" class=""><div class="">On 10 Oct 2015, at 00:14, Chris Muller &lt;<a href="mailto:asqueaker@gmail.com" class="">asqueaker@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Wow, all I need to do is work up an email question, and it seems to lead myself to a solution! &nbsp; :-) &nbsp; In this case, I can't use&nbsp;JQueryInstance&gt;&gt;#replaceWith: only lets the user pass a String argument, not a jQuery argument.&nbsp; Because the version of JSObject&gt;&gt;#render: always returns a String no matter what, which will never let a JSObject subclass render its code onto the stream.&nbsp; Strange!<div class=""><br class=""></div><div class=""><div class="">And, so, the solution was to #call: 'replaceWith' with: myJQPost myself.&nbsp; Here is the code, for comparison to the original:</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp;html script defer with:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((html jQuery id: buttonId) onClick:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(<font color="#38761d" class="">(html jQuery id: replacementId) call: 'replaceWith' with: ajaxRequest) </font>asFunction).<br class=""></div><div class=""><br class=""><div class="">I think this is slowing my learning of Seaside -- the thought that I should be able to use all the convenience methods and get all the power of JQuery, but, in fact, some of these methods provide no way to render the other versions of the jQuery calls which take different argument types.&nbsp; Only the string types are supported.&nbsp; Am I right about this?<br class=""></div><div class=""><br class=""></div><div class="">Another example is the "data" argument of a $.ajax(...) request.&nbsp; Seaside renders a Javascript array, but then calls .join("&amp;") on it!&nbsp; Strings only.... &nbsp;:(</div><div class=""><br class=""></div><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Oct 9, 2015 at 4:52 PM, Chris Muller <span dir="ltr" class="">&lt;<a href="mailto:asqueaker@gmail.com" target="_blank" class="">asqueaker@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class="">Thanks Johan, that's the kind of advice I need, as there are many ways to do things.<br class=""><br class="">Now, I am stumped (for hours!) on another very similar problem, except instead of a single variable, I simply want to pass an argument of type "jQuery" into jQuery's replaceWith() function, called within a onClick handler method.&nbsp; So, in my renderContentOn:, I wrote:<br class=""><br class="">&nbsp; &nbsp; &nbsp;| ajaxRequest |<br class="">&nbsp; &nbsp; &nbsp;ajaxRequest := (html jQuery post<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: html actionUrl;<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataType: 'html') html: [ &nbsp;: replaceHtml | self invoke. &nbsp;replaceHtml render: resultWidget ].<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;....<br class="">&nbsp; &nbsp; &nbsp;html script defer with:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((html jQuery id: buttonId) onClick:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;((html jQuery id: replacementId) replaceWith: ajaxRequest asJavascript) asFunction).<div class=""><br class=""></div><div class="">However, as before, the argument to replaceWith() is being rendered as a Javascript string literal instead of the code itself. &nbsp;(See red quotes, below, I want it to stop rendering those quotes!).</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; $("#id3").click(function(){$("#id4").replaceWith(<b class=""><font color="#cc0000" class="">"</font></b>$.post(&amp;quot;/puf&amp;quot;,[&amp;quot;_s=C8vA8l5UNoUsGTpf&amp;quot;,&amp;quot;_k=B_Wk6EYdovACqAgV&amp;quot;,&amp;quot;2&amp;quot;].join(&amp;quot;&amp;amp;&amp;quot;),&amp;quot;html&amp;quot;)<font color="#990000" class=""><b class="">"</b></font>)})<br class=""></div><div class=""><br class=""></div><div class="">I tried many different variations, no success.&nbsp; This must be something simple...</div><div class=""><br class=""></div><div class="">Thank you.</div></div><div class=""><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Oct 9, 2015 at 2:25 AM, Johan Brichau <span dir="ltr" class="">&lt;<a href="mailto:johan@inceptive.be" target="_blank" class="">johan@inceptive.be</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Chris,<br class="">
<br class="">
I notice you figured out the use of #alias:<br class="">
<br class="">
Use the JS generation facilities only when you need to *generate* code. For example, to embed a server-side callback or, in general, when the code can only be dynamically constructed.<br class="">
In your case, I would do the following:<br class="">
<br class="">
(JSStream on: ‘console.log(event)’)<br class="">
<br class="">
Just because you can write it in Smalltalk does not mean you should :)<br class="">
<span class=""><font color="#888888" class=""><br class="">
Johan<br class="">
</font></span><br class="">
ps: your contributions are in my inbox, I will process them asap<br class="">
<div class=""><div class=""><br class="">
&gt; On 09 Oct 2015, at 03:46, Chris Muller &lt;<a href="mailto:asqueaker@gmail.com" target="_blank" class="">asqueaker@gmail.com</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt; Found something.&nbsp; JSAlias.<br class="">
&gt;<br class="">
&gt;&gt;&nbsp; &nbsp; html span<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;class: 'PufMessageWidget' ;<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;id: (self assureHtmlIdUsing: html) ;<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onClick: ((html javascript logger call: 'log' with: 'event')<br class="">
&gt;&gt; asFunction: #('event')).<br class="">
&gt;<br class="">
&gt; I gave up on onClick: since I guess its better to set up event<br class="">
&gt; bindings through jQuery's API.&nbsp; This binding does what I want, no<br class="">
&gt; syntax error.<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp; &nbsp;html script defer with:<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((html jQuery id: (self assureHtmlIdUsing: html)) onClick:<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;((html javascript logger call: 'log' with: (html<br class="">
&gt; javascript alias: 'event')) asFunction: #('event'))).<br class="">
&gt;<br class="">
&gt; It seems like a pretty wordy way to write console.log(event), but the<br class="">
&gt; intent reads clearly so, that's good..<br class="">
</div></div><div class=""><div class="">&gt; _______________________________________________<br class="">
&gt; seaside mailing list<br class="">
&gt; <a href="mailto:seaside@lists.squeakfoundation.org" target="_blank" class="">seaside@lists.squeakfoundation.org</a><br class="">
&gt; <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank" class="">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br class="">
<br class="">
_______________________________________________<br class="">
seaside mailing list<br class="">
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank" class="">seaside@lists.squeakfoundation.org</a><br class="">
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank" class="">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br class="">
</div></div></blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div></div></div></div></div>
_______________________________________________<br class="">seaside mailing list<br class=""><a href="mailto:seaside@lists.squeakfoundation.org" class="">seaside@lists.squeakfoundation.org</a><br class="">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside<br class=""></div></blockquote></div><br class=""></div></body></html>