質問

I have a component (ItemTree) which has 3 embeded components. The first (ItemTreeList) is a list of items to select. The second (ItemGIDE) shows properties for the item you selected.

How do I tell ItemGIDE to update when a new selection is made on ItemTreeList?

Firstly, This is more complicated than I'm making it out to be. The ItemTreeList has hirarchy with node types and node instances. It has collapsable divs and when clicking on either a top level hirarchy item or an instance below, will set various variables on other objects. So, a whole lot happens on a single click. I've got the ItemTreeList to update itself without refreshing the whole page. Just need to 'Announce' to the other component (ItemGIDE) that it needs to refresh (Again without refreshing the whole page).

  • I've got Jquery and Ajax at hand.
  • I'm using Visualage Smalltalk 8.5.0 with Seaside 3.0. -I've been thinking about a call to ItemTree to tell its sub components to update?
  • I've been thinking about using 'announce' to 'announce' to other components to update?
  • I've been doing actual programming for less than 6 months?
役に立ちましたか?

解決

The book Dynamic Web Development with Seaside contains a draft chapter about JQuery. In there you find an section called Replace a Component with an example of what you ask for:

OuterComponent>>renderContentOn: html
  html div
    id: (id := html nextId);
    with: child.
  html anchor
    onClick: ((html jQuery id: id) load
      html: [ :r | 
        child := OtherComponent new;
        r render: child ]);
    with: 'Change Component'

The code shows the render method of the outer component. It assumes that the component has a variable called child that is initialized with the component shown in the initial render. Furthermore, it assumes that the component has a variable called id that is set during rendering to remember the target DOM node where the child component is rendered. In the AJAX callback of the anchor you replace the child component with OtherComponent new and re-render the contents of the target node.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top