Documentation Center

The scripting

You need to write relatively more javascript than XSL when implementing pop-up menus.

There are two different button handlers:
  • one that handles the button produced by the XSL
  • and another which figures out what elements are legal children of the current one and creates a series of buttons, one for each allowed child type.
The code example is relatively simple since "first-level" buttons are added to section elements and thus always have the same possible children. In a more complex structure, buttons could be inserted for a number of different types, giving different sets of possible insertions at different points.

Alternatively, the call to getAllowedChildren could be removed and an array of specific types could be used instead.