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.

Creator Functions

Place holder page for creating a component using a creator function instead of autoInit.

IN PROGRESS

Create the Component

Namespace - A single global variable that becomes the container for your code. It helps keep code well, contained, meaning there's less chance of bad interactions with other code. It's also easier to read.

Creator function - The function that starts it all off - this is what will be called to create your component.

So let's start by putting our bar graph code within a variable called "fluid" since this is the standard namespace for fluid's Infusion components, and call our component "barGraph". That means our creator function will be "fluid.barGraph = some function." We'll also send the creator function two things: a container, and options. These variables are required for the Infusion function called inside the creator function that returns a component object we can start building on. This is also referred to as initializing a component. Once we have initialized our component, we can return it to complete a very basic bar graph component that doesn't do anything yet.

fluid = fluid || {};

(function ($, fluid) {

    //we'll add some private methods here

    fluid.barGraph = function (container, options) {
        var that = fluid.initView("fluid.barGraph", container, options);

        //we'll add some public methods here

        return that;
    };

    //we'll put our default options here

})(jQuery, fluid);

A few things to note here:

jQuery - Infusion is built using functionality in the jQuery framework, so we'll require it in our component as well.

initView -

container & options -