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

Skip to end of metadata
Go to start of metadata

fluid.initView(componentName, container, userOptions)

A "view component" is the central initialiation method called as the first act of every Fluid component. This function automatically merges user options with defaults, attaches a DOM Binder to the instance, and configures events. Alternatively, a "view component" is composed of a "little component", "model component", and an "evented component".

fluid.initView = function (componentName, container, userOptions)

File name: Fluid.js

Parameters

name (Object) The component name
container (Object) The component container
options (Object) The component options

Return value

Object A module with merged options, DOM Binder and configured events


How to create a view component

We want to create an Uploader view component containing a sub-component that identifies the correct uploading strategy for our progressively-enhanced uploader. The Uploader view component can be instantiated in two different ways. See the following examples below:

A direct call to the framework API:

var container = $(".flc-uploader");
var that = fluid.initView("fluid.uploader", container, {
    components: {
        uploaderImpl: {
            type: "fluid.uploaderImpl",
            container: "{uploader}.container",
            options: "{uploader}.uploaderOptions"
        }
    }
});

Indirect IoC-driven approach:

fluid.defaults("fluid.uploader", {
    gradeNames: ["fluid.viewComponent", "autoInit"],
    components: {
        uploaderImpl: {
        type: "fluid.uploaderImpl",
        container: "{uploader}.container",
        options: "{uploader}.uploaderOptions"
    }
});

A component grade is required by setting the gradeNames property to "fluid.viewComponent". The "autoInit" grade is included so that the component's actual creator function doesn't need to be written at all.

  • No labels