This example illustrates how to replace the content of a Button's Menu on the fly.
attribute is documented as being
writeOnce meaning that the
attribute can only be set once, either via the the object literal passed to the
constructor, or on an instance via the
method. However, although the
attribute can only be set once, the
Menu widget's API
makes it easy to replace the content of a Menu instance on the fly. In this
example, the content of the "Pizza Size" Menu is controlled by the type of pizza
the user has selected.
The code used to replace the content of the "Pizza Size" Menu in this
example resides in the
onCheckedChange function, a listener for
event of the two radio buttons. Each listener receives an array of MenuItem
configuration properties, used to rebuild the content of the "Pizza Size" Menu,
either by using the Menu's
method, or by setting the Menu's
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.