Re: script: [...] value parameter
Bob Nemec <[email protected]> Mon, 24 Oct 2022 12:50:30 +0000 (UTC)
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
--===============2881414976962266759== Content-Type: multipart/alternative; boundary="----=_Part_1853476_89376033.1666615830102" ------=_Part_1853476_89376033.1666615830102 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable (Also posted on Discord) ... Thanks: we already use the secondary callback= s & passenger patters. In this case, we have a large calendar component for= which we're trying to avoid rendering too much cell specific code (html co= ntent gets crazy big).=C2=A0=C2=A0Ideally, I'd have one script for the cale= ndar that uses JQueryInstance>>closest: to get the div id / passenger, pass= that to a script: [...] block, and then have the browser run the script bl= ock result.=C2=A0 That works (and we're using it) for static onMouseOver: js script content, = but having new content on each mouseover provided by a script: [...] block = is where I'm stuck... using the closest: pattern removes the need for cell = div specific scripts (with a noticeable render speed=C2=A0 improvement), bu= t I can't pass along the closest div to the script: [...] block to build ce= ll specific content.=C2=A0=C2=A0 Feels like it a...=C2=A0script: [:script :value | ...] value: (js script)..= .pattern should work with a closest: div parameter. Great opportunity for m= e to learn more Seaside internal :-)=C2=A0=C2=A0 Bob On Monday, October 24, 2022 at 03:08:24 a.m. EDT, Johan Brichau <joh= [email protected]> wrote: =20 =20 I copy/paste my response on the Discord channel: =20 - An ajax request with Seaside JQuery can combine multiple secondary cal= lbacks and a single primary callback. You can find out which are which in t= he method comments on JQAjax. In short: a primary callback is a response-ge= nerating callback, while secondary callbacks are callbacks that pass values= from the client to the server. As such, you can construct what you want al= ready as follows: | value | html jQuery ajax=20 callback: [ :v | value :=3D v ] value: (html jQuery this propertyAt: 'id= '); script: [ :s | ...use value in the generation of the script... ] - [9:40 AM]Also, take a look at passengers if you want to store objects = and retrieve them by id. Seaside has this mechanism built-in for you: | v= alue | html button passenger: self; onClick: (html jQuery ajax=20 callback: [ :v | value :=3D v ] passenger: (html jQuery this); On 21 Oct 2022, at 19:48, Bob Nemec <[email protected]> wrote: Cross posted from Seaside Discord channel... I would like to have an 'html ajax script: [...]' method that has a callbac= k:value: pattern.=C2=A0 Something like...=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0html ajax script: [:script := value | ...] value: (html jQuery this propertyAt: 'id')=C2=A0 Then in the script block 'value' would get the id of 'this', which in an aj= ax callback is undefined.=C2=A0This would allow server code to use browser = information to build the script.=C2=A0 Anyone done this? Bob Nemec _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside =20 ------=_Part_1853476_89376033.1666615830102 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div class=3D"ydp463fbbe9yahoo-style-wrap" style= =3D"font-family:lucida console, sans-serif;font-size:13px;"><div></div> <div dir=3D"ltr" data-setdir=3D"false"><div><div dir=3D"ltr" data-s= etdir=3D"false">(Also posted on Discord) ... Thanks: we already use the sec= ondary callbacks & passenger patters. In this case, we have a large cal= endar component for which we're trying to avoid rendering too much cell spe= cific code (html content gets crazy big).</div><div> </div><div>= Ideally, I'd have one script for the calendar that uses JQueryInstance>&= gt;closest: to get the div id / passenger, pass that to a script: [...] blo= ck, and then have the browser run the script block result. </div><div>= <br></div><div>That works (and we're using it) for static onMouseOver: js s= cript content, but having new content on each mouseover provided by a scrip= t: [...] block is where I'm stuck... using the closest: pattern removes the= need for cell div specific scripts (with a noticeable render speed i= mprovement), but I can't pass along the closest div to the script: [...] bl= ock to build cell specific content. </div><div><br></div><div>Fe= els like it a... </div><div>script: [:script :value | ...] value: (js = script)</div><div>...pattern should work with a closest: div parameter. Gre= at opportunity for me to learn more Seaside internal :-) </div><= /div><br></div><div dir=3D"ltr" data-setdir=3D"false">Bob</div> =20 </div><div id=3D"yahoo_quoted_7101938615" class=3D"yahoo_quoted"> <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s= ans-serif;font-size:13px;color:#26282a;"> =20 <div> On Monday, October 24, 2022 at 03:08:24 a.m. EDT, Johan= Brichau <[email protected]> wrote: </div> <div><br></div> <div><br></div> <div><div id=3D"yiv2078344877"><div>I copy/paste my respons= e on the Discord channel:<div class=3D"yiv2078344877"><br clear=3D"none" cl= ass=3D"yiv2078344877"></div><div class=3D"yiv2078344877"><ol style=3D"margi= n:0px;padding:0px;border:0px;font-family:Whitney, Helvetica, Arial, sans-se= rif;font-size:16px;vertical-align:baseline;list-style:none;min-height:0px;o= rphans:2;widows:2;background-color:rgb(255, 255, 255);" class=3D"yiv2078344= 877scrollerInner-2PPAp2"><li id=3D"yiv2078344877chat-messages-1033645149160= 480829" style=3D"margin:0px;padding:0px;border:0px;font-style:inherit;font-= family:inherit;vertical-align:baseline;outline:none;" class=3D"yiv207834487= 7messageListItem-ZZ7v6g"><div style=3D"margin:0px 0px;padding-left:72px;bor= der:0px;font-style:inherit;font-family:inherit;vertical-align:baseline;outl= ine:0px;position:relative;padding-right:48px !important;" class=3D"yiv20783= 44877groupStart-3Mlgv1 yiv2078344877hasReply-2Cr4KE yiv2078344877wrapper-30= -Nkg yiv2078344877message-2CShn3 yiv2078344877zalgo-26OfGz yiv2078344877coz= yMessage-1DWF9U yiv2078344877cozy-VmLDNB"><div style=3D"margin:0px;padding:= 0px;border:0px;font-style:inherit;font-family:inherit;vertical-align:baseli= ne;outline:0px;" class=3D"yiv2078344877contents-2MsGLg"><div id=3D"yiv20783= 44877message-content-1033645149160480829" style=3D"margin:0px 0px 0px;paddi= ng:0px 0px 0px 72px;border:0px;font-style:inherit;font-family:inherit;verti= cal-align:baseline;outline:0px;position:relative;overflow:hidden;" class=3D= "yiv2078344877markup-eYLPri yiv2078344877messageContent-2t3eCI">An ajax req= uest with Seaside JQuery can combine multiple secondary callbacks and a sin= gle primary callback. You can find out which are which in the method commen= ts on JQAjax. In short: a primary callback is a response-generating callbac= k, while secondary callbacks are callbacks that pass values from the client= to the server.=20 As such, you can construct what you want already as follows: <pre style=3D"margin-top:6px;margin-bottom:0px;padding:0px;border:0px;font-= style:inherit;font-family:Consolas, Mono Sans Sans Vera Sans Mono Monaco, C= ourier, monospace;vertical-align:baseline;border-radius:4px;white-space:pre= -wrap;max-width:90%;" class=3D"yiv2078344877"><code style=3D"margin:0px;pad= ding:0.5em;border:1px solid;font-style:inherit;font-family:Consolas, Mono S= ans Sans Vera Sans Mono Monaco, Courier, monospace;vertical-align:baseline;= display:block;border-radius:4px;" class=3D"yiv2078344877hljs yiv2078344877s= crollbarGhostHairline-2LpzZ9 yiv2078344877scrollbar-3vVt8d">| value | html jQuery ajax=20 callback: [ :v | value :=3D v ] value: (html jQuery this propertyAt: 'id= '); script: [ :s | ...use value in the generation of the script... ]</code><= /pre></div></div><div style=3D"margin:0px;padding:0px;border:0px;font-style= :inherit;font-family:inherit;vertical-align:baseline;outline:0px;" class=3D= "yiv2078344877buttonContainer-1502pf"><div style=3D"margin:0px;padding:0px = 14px 0px 32px;border:0px;font-style:inherit;font-family:inherit;vertical-al= ign:baseline;outline:0px;z-index:1;" class=3D"yiv2078344877buttons-3dF5Kd y= iv2078344877container-2gUZhU yiv2078344877isHeader-2bbX-L"><div style=3D"ma= rgin:0px;padding:0px;border:0px;font-style:inherit;font-family:inherit;vert= ical-align:baseline;outline:0px;display:grid;min-height:32px;border-radius:= 4px;transition:0.1s ease-out 0s, 0.1s ease-out 0s;position:relative;overflo= w:hidden;" class=3D"yiv2078344877wrapper-2vIMkT"><div style=3D"margin:0px;p= adding:4px;border:0px;font-style:inherit;font-family:inherit;vertical-align= :baseline;outline:0px;display:flex;min-height:24px;min-width:24px;cursor:po= inter;position:relative;" class=3D"yiv2078344877button-3bklZh"></div><div s= tyle=3D"margin:0px;padding:4px;border:0px;font-style:inherit;font-family:in= herit;vertical-align:baseline;outline:0px;display:flex;min-height:24px;min-= width:24px;cursor:pointer;position:relative;" class=3D"yiv2078344877button-= 3bklZh"></div><div style=3D"margin:0px;padding:4px;border:0px;font-style:in= herit;font-family:inherit;vertical-align:baseline;outline:0px;display:flex;= min-height:24px;min-width:24px;cursor:pointer;position:relative;" class=3D"= yiv2078344877button-3bklZh"></div><div style=3D"margin:0px;padding:4px;bord= er:0px;font-style:inherit;font-family:inherit;vertical-align:baseline;outli= ne:0px;display:flex;min-height:24px;min-width:24px;cursor:pointer;position:= relative;" class=3D"yiv2078344877button-3bklZh"></div></div></div></div></d= iv></li><li id=3D"yiv2078344877chat-messages-1033646070099623978" style=3D"= margin:0px;padding:0px;border:0px;font-style:inherit;font-family:inherit;ve= rtical-align:baseline;outline:none;" class=3D"yiv2078344877messageListItem-= ZZ7v6g"><div style=3D"margin:0px;padding-left:72px;border:0px;font-style:in= herit;font-family:inherit;vertical-align:baseline;outline:0px;position:rela= tive;padding-right:48px !important;" class=3D"yiv2078344877wrapper-30-Nkg y= iv2078344877cozyMessage-1DWF9U yiv2078344877cozy-VmLDNB yiv2078344877zalgo-= 26OfGz yiv2078344877message-2CShn3"><div style=3D"margin:0px;padding:0px;bo= rder:0px;font-style:inherit;font-family:inherit;vertical-align:baseline;out= line:0px;" class=3D"yiv2078344877contents-2MsGLg"><span style=3D"margin:0px= 0px 0px;padding:0px;border:0px;font-style:inherit;font-family:inherit;vert= ical-align:baseline;outline:0px;display:inline-block;cursor:default;width:5= 6px;text-align:right;z-index:1;" class=3D"yiv2078344877timestamp-p1Df1m yiv= 2078344877latin24CompactTimeStamp-2pXUBq yiv2078344877timestampVisibleOnHov= er-9PEuZS yiv2078344877alt-1dvXnH"><span style=3D"width:0px;display:inline-= block;" class=3D"yiv2078344877separator-AebOhG">[</span>9:40 AM<span style= =3D"width:0px;display:inline-block;" class=3D"yiv2078344877separator-AebOhG= ">]</span></span><div id=3D"yiv2078344877message-content-103364607009962397= 8" style=3D"margin:0px 0px 0px;padding:0px 0px 0px 72px;border:0px;font-sty= le:inherit;font-family:inherit;vertical-align:baseline;outline:0px;position= :relative;overflow:hidden;" class=3D"yiv2078344877markup-eYLPri yiv20783448= 77messageContent-2t3eCI">Also, take a look at passengers if you want to sto= re objects and retrieve them by id. Seaside has this mechanism built-in for= you: <pre style=3D"margin-top:6px;margin-bottom:0px;padding:0px;border:0px;font-= style:inherit;font-family:Consolas, Mono Sans Sans Vera Sans Mono Monaco, C= ourier, monospace;vertical-align:baseline;border-radius:4px;white-space:pre= -wrap;max-width:90%;" class=3D"yiv2078344877"><code style=3D"margin:0px;pad= ding:0.5em;border:1px solid;font-style:inherit;font-family:Consolas, Mono S= ans Sans Vera Sans Mono Monaco, Courier, monospace;vertical-align:baseline;= display:block;border-radius:4px;" class=3D"yiv2078344877hljs yiv2078344877s= crollbarGhostHairline-2LpzZ9 yiv2078344877scrollbar-3vVt8d">| value | html button passenger: self; onClick: (html jQuery ajax=20 callback: [ :v | value :=3D v ] passenger: (html jQuery this);</code= ></pre></div></div></div></li></ol><div class=3D"yiv2078344877"><br clear= =3D"none" class=3D"yiv2078344877"></div><div><br clear=3D"none" class=3D"yi= v2078344877"><blockquote type=3D"cite" class=3D"yiv2078344877"><div id=3D"y= iv2078344877yqt33596" class=3D"yiv2078344877yqt7058150919"><div class=3D"yi= v2078344877">On 21 Oct 2022, at 19:48, Bob Nemec <<a rel=3D"nofollow noo= pener noreferrer" shape=3D"rect" ymailto=3D"mailto:[email protected]" target= =3D"_blank" href=3D"mailto:[email protected]" class=3D"yiv2078344877">bobn@ro= gers.com</a>> wrote:</div><br clear=3D"none" class=3D"yiv2078344877Apple= -interchange-newline"><div class=3D"yiv2078344877"><div class=3D"yiv2078344= 877"><div style=3D"font-family:lucida console, sans-serif;font-size:13px;" = class=3D"yiv2078344877yahoo-style-wrap"><div dir=3D"ltr" class=3D"yiv207834= 4877">Cross posted from Seaside Discord channel...</div><div dir=3D"ltr" cl= ass=3D"yiv2078344877"><br clear=3D"none" class=3D"yiv2078344877"></div><div= dir=3D"ltr" class=3D"yiv2078344877"><div class=3D"yiv2078344877"><div clas= s=3D"yiv2078344877">I would like to have an 'html ajax script: [...]' metho= d that has a callback:value: pattern. </div><div class=3D"yiv207834487= 7"><br clear=3D"none" class=3D"yiv2078344877"></div><div class=3D"yiv207834= 4877">Something like... </div><div class=3D"yiv2078344877">  = ; html ajax script: [:script :value | ...] value: (html jQuery t= his propertyAt: 'id') </div><div class=3D"yiv2078344877"><br clear=3D"= none" class=3D"yiv2078344877"></div><div class=3D"yiv2078344877">Then in th= e script block 'value' would get the id of 'this', which in an ajax callbac= k is undefined. </div><div dir=3D"ltr" class=3D"yiv2078344877">This wo= uld allow server code to use browser information to build the script. = </div><div class=3D"yiv2078344877"><br clear=3D"none" class=3D"yiv207834487= 7"></div><div class=3D"yiv2078344877">Anyone done this?</div></div><br clea= r=3D"none" class=3D"yiv2078344877"></div><div dir=3D"ltr" class=3D"yiv20783= 44877"><br clear=3D"none" class=3D"yiv2078344877"></div><div dir=3D"ltr" cl= ass=3D"yiv2078344877">Bob Nemec</div><div dir=3D"ltr" class=3D"yiv207834487= 7"><br clear=3D"none" class=3D"yiv2078344877"></div></div></div>___________= ____________________________________<br clear=3D"none" class=3D"yiv20783448= 77">seaside mailing list<br clear=3D"none" class=3D"yiv2078344877"><a rel= =3D"nofollow noopener noreferrer" shape=3D"rect" ymailto=3D"mailto:seaside@= lists.squeakfoundation.org" target=3D"_blank" href=3D"mailto:seaside@lists.= squeakfoundation.org" class=3D"yiv2078344877">[email protected]= n.org</a><br clear=3D"none" class=3D"yiv2078344877">http://lists.squeakfoun= dation.org/cgi-bin/mailman/listinfo/seaside<br clear=3D"none" class=3D"yiv2= 078344877"></div></div></blockquote></div><br clear=3D"none" class=3D"yiv20= 78344877"></div></div></div><div class=3D"yqt7058150919" id=3D"yqt37085">__= _____________________________________________<br clear=3D"none">seaside mai= ling list<br clear=3D"none"><a shape=3D"rect" ymailto=3D"mailto:seaside@lis= ts.squeakfoundation.org" href=3D"mailto:[email protected]"= >[email protected]</a><br clear=3D"none"><a shape=3D"rect"= href=3D"http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside= " target=3D"_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listi= nfo/seaside</a><br clear=3D"none"></div></div> </div> </div></body></html> ------=_Part_1853476_89376033.1666615830102-- --===============2881414976962266759== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18Kc2Vhc2lkZSBt YWlsaW5nIGxpc3QKc2Vhc2lkZUBsaXN0cy5zcXVlYWtmb3VuZGF0aW9uLm9yZwpodHRwOi8vbGlz dHMuc3F1ZWFrZm91bmRhdGlvbi5vcmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3NlYXNpZGUK --===============2881414976962266759==--