Creating new widgets or rearranging the layout of widgets at runtime is the AJAX version of dynamic content. The two key functions to unlock such magic are createComponent()
and reflow()
.
Reflow tells the layout engine to re-render the specified container. This is required after adding components to the container or adjusting the layout of the components of the container. The reflowParent()
helper function can be used to reflow the parent container without having to lookup the parent. Consider the example presented on the Dynamic Content tab of this chapter's sample application, MasteringClientCustomization
:
Each Move Up button shares the upButtonClick()
function for its onClick()
event:
upButtonClick:
function(inSender)
{
try
{
var
thisControl
=
inSender.parent;
var
newIndex
=
thisControl.parent.indexOfControl(thisControl)
-
1;
if(newIndex
>=
0){
thisControl.parent.moveControl(thisControl,(newIndex));
thisControl.reflowParent();
...