Subcomponents

Documentation for a historical release of Infusion: 1.3
Please view the Infusion Documentation site for the latest documentation.
If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Subcomponents

Overview

Creation

The creator function of any component is responsible for creating subcomponents, both those required by the component and those requested by the implementor. Creation is accomplished using the fluid.initSubcomponents() functions:

fluid.initSubcomponent(that, className, args);
fluid.initSubcomponents(that, className, args);

Parameters

that

The first parameter is the parent component to which the subcomponent should be attached. Inside a component creator function, this will be the that object returned by fluid.initView().

The that object is expected to contain the configuration information for the subcomponent in its options structure. They may have been specified in the defaults for the component, or passed in as options to the creator function, or both. See fluid:Configuration for more information about the options used to configure subcomponents.

className

The className parameter defines the category of subcomponent to instantiate, and maps to the name of the configuration options present in the that.options object. (See fluid:Configuration for more information). Users should consult the documentation for the individual subcomponent to determine its type. Implementors creating their own subcomponents must select a unique category for them.

args

The args parameter is an array of JavaScript objects that will be passed to the creator function of the subcomponent. The arguments required are defined by the subcomponent, and are not bound by the container, options convention used by regular components.

Example

In the example below, a parent component, newComponent, creates a subcomponent, subComp1:

fluid.newComponent = function (container, options) { var that = fluid.initView("fluid.newComponent", container, options); ... // subComp1 is of class "subComponent1" and its creator function // requires the container and events as parameters that.subComp1 = fluid.initSubcomponents(that, "subComponent1", [that.container, that.events]); ... }; fluid.defaults("fluid.newComponent", { subComponent1: { type: "fluid.someSubComponent", options: { selectors: { part1: ".flc-part1" } } }, ... });

Configuration

Subcomponents can be configured in the defaults for the parent component. The key in the defaults is the classname of the subcomponent - this is what is passed as the second parameter to initSubcomponent(). The value is an object containing a type and options. The type is the fully namespaced subcomponent creator function name. The options are the subcomponent creator function's supported options.

Types of subcomponents

Several subcomponents are currently in use by Fluid components: