[Seaside] repeats on home-made components
Avi Bryant
seaside@lists.squeakfoundation.org
Thu, 18 Jul 2002 11:14:07 -0700 (PDT)
On Thu, 18 Jul 2002, Tim Rowledge wrote:
> For example for demo purposes I needed to have five questions displyed
> on a single page and the best I could do quickly was
> html
> ...
> <page sea:id="pane1"></page>
> <page sea:id="pane2"></page>
> ....
>
> addBindingsTo: template
> (template elementNamed: 'pane1')
> class....
> set: #theQuestion toPath: #theQuestion1
> (template elementNamed:'pane2')
> class....
> etc
> plus implementing theQuestion1, theQuestion2 etc. Yuck! Works fine for
> the demo though :-)
>
> What's the least I can do to improve this so I can do something more
> flexible like
> <page sea:id="pane/panes"></page>
Well, you need to separate the loop out from your component, so you
probably want something like
<div sea:id="question/questions">
<page sea:id="pane"></page>
</div>
(or if you don't like having the <div>s that will create, use the <repeat>
tag which won't show up as anything).
Then you want something like
(template elementNamed: 'pane')
class...;
set: #theQuestion toPath: 'question'
The path there is referencing the local "question" variable created for
that repeat.
Make sense?
Avi