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.
Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings