[Seaside] dynamic selection - liveCallback question

radoslav hodnicak rh at 4096.sk
Tue Jun 14 11:29:03 CEST 2005



> Hi,
>
> I would like to have two select on the same page, and the content of
> the second one would depend on the content of the first one
> dynamicaly. I tried something with the liveCallback:
>
> renderContentOn: html
>  html form: [
>    html selectFromList: #(a b c)
>      selected: #a callback: [:sel] labels: [:ea | ea asString]
>      liveCallback: [:sel :h |
>        selected := sel. self renderContentOn: h].
>    ].
>
>    html form: [
>      html selectFromList: ((selected = #a) ifTrue: [ #(aa bb cc)]
> ifFalse: [ #(ba bb bc) ])
>        selected: #aa callback: [:sel] labels: [:ea | ea asString]
>    ].

make the rendering of the second form a separate method (like 
renderFormOn:) and give it a CSS name, like

html cssId: 'dynamic-form'; form: [ ... ]

so your code would then look like

renderContentOn: html
   html form: [
     html selectFromList: #(a b c)
       selected: #a callback: [:sel] labels: [:ea | ea asString]
       liveCallback: [:sel :h |
         selected := sel. self renderFormOn: h].
     ].

     self renderFormOn: html

the thing to remember about live stuff is that the update must send new 
content for an element that can be found using getElementById() in 
javascript. If you just say form: [...] it doesn't know *which* element to 
update

rado


More information about the Seaside mailing list