<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap:break-word"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Hi Esteban,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">I think it's a great idea. I too run into this problem a lot. I would suggest, however, to have the registry at the render loop level, not the component level. There are cases in which you may need to access the ID of an element rendered by a different component.</div> <br> <div id="bloop_sign_1505142053791490048" class="bloop_sign">Cheers,</div><div id="bloop_sign_1505142053791490048" class="bloop_sign">Max</div> <br><p class="airmail_on">On 11 September 2017 at 16:58:53, Esteban A. Maringolo (<a href="mailto:emaringolo@gmail.com">emaringolo@gmail.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>


<title></title>


<div dir="ltr">
<div>Hi all, me again :)</div>
<div><br></div>
<div>Related with the previous mail about naming script builder
selectors, another thing I find myself repeating over and over, is
the creation, initialization and of course access of instance
variables holding references to dynamically generated element id
(vía `html nextId`).</div>
<div><br></div>
<div>Given that today's webpages, even the simples ones, use a lot
of Javascript with Jquery at the client side, wouldn't it be a good
addition to have a registry of these IDs at the component level?
This way we would avoid creating lots of instance variables just to
keep a reference to those IDs.</div>
<div><br></div>
<div>In some cases that reference is only needed in the context of
a single method, so a temporal variable is enough, but if the code
is complex and well factored you can only pass these IDs as
arguments or make the temp an instance variable.</div>
<div><br></div>
<div>So I'm thinking about having something like:</div>
<div><br></div>
<div>renderSomethingOn: html</div>
<div>  self atId: #content put: html nextId.<br></div>
<div>  html nextIdFor: self at: #heading.</div>
<div>  html div</div>
<div>    id: (self atId: #content);</div>
<div>    with: [html heading id: (self atId: #heading);
with: 'Foo baz'.</div>
<div>            "..."</div>
<div>       ].</div>
<div><br></div>
<div>WAHtmlCanvas>>#nextIdFor: aWAComponent at: aSymbol</div>
<div>   aWAComponent atId:aSymbol put: self nextId</div>
<div><br></div>
<div><br></div>
<div>These selectors aren't well thought, but the idea is that you
can assign whatever you want to the registry, or you can use the
canvas nextId to assing it automatically to the registry.</div>
<div><br></div>
<div>The registry could be lazy initialized, so components that
never access it won't have an extra, empty instance of it (a
GRSmallDictionary probably).</div>
<div><br></div>
<div>Pros:</div>
<div>- It would save the use of lots of instance variables</div>
<div>- It would "standardize" a way to access those ids other than
#nextId/#lastId without requiring accessor methods for the
variables.</div>
<div><br></div>
<div>Cons</div>
<div>- It would require an extra instance variable at WAComponent
to reference the registry</div>
<div><br></div>
<div>To compensate the last one there could be a particular
WAComponent subclass that has this feature, but I suspect most
instances would subclass from it, so it would be the same as doing
it in WAComponent directly.</div>
<div><br></div>
<div><br></div>
<div>What do you think?</div>
<div><br></div>
<div>Regards,</div>
<br clear="all">
<div>
<div class="gmail_signature" data-smartmail="gmail_signature">
Esteban A. Maringolo</div>
</div>
</div>


_______________________________________________<br>seaside-dev mailing list<br><a href="mailto:seaside-dev@lists.squeakfoundation.org">seaside-dev@lists.squeakfoundation.org</a><br><a href="http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev">http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev</a><br></div></div></span></blockquote></body></html>