[Seaside] Appending to list of model objects & updating (sub)component list with scriptaculous / Ajax

itsme213 itsme213 at hotmail.com
Fri Jul 28 07:29:33 UTC 2006

I have an SUComponent subclass whose domain object contains a list of
Things. The SUComponent contains a list of other subcomponents in an
OrderedCollection instance variable #subViews, each subcomponent on 1 Thing.
Each subcomponent renders an InPlaceEditor.

I want to use Ajax to add Things to the domain list and update the
subcomponent list. Below is the #renderContentOn: for the SUComponent.

renderContentOn: html
html div: [
 html div
  id: 'ID1';
  with: [
   self renderSummaryOn: html.    " simply renders -- We Have <N> Things"
   self subViews do: [ : sv | html render: sv ]
    " renders an InPlaceEditor on each Thing; works until '++' below".
 html anchor
  onClick: (
   html ajax
    id: 'ID1';
    callback: [ :renderer |
     | newThing |
     newThing := self model addThing: 'a new one'.
     subViews add: (SubView new thing: newThing).
     self renderSummaryOn: renderer.
     self subViews do: [ :sv | renderer render: sv ]
  with: '++'.

Almost works, except  that after pressing the '++':

(a) the last added Thing does not have the snippet of Javascript code that
the others do:

(b) the InPlaceEditors of the preceding Things no longer work.

What am I doing wrong?

Thanks in advance!

More information about the Seaside mailing list