YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
This example illustrates how to replace the content of a Button's Menu on the fly.
Button's
menu
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
set
method. However, although the
menu
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
the
checkedChange
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
clearContent
method, or by setting the Menu's
itemData
property.
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.
Copyright © 2013 Yahoo! Inc. All rights reserved.