This documentation is currently being moved to our new documentation site.

Please view or edit the documentation there, instead.

If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Add methods to a component using invokers or members

To add methods to a component, use invokers (sparingly) or members. Don't add them directly to 'that' in an init function (i.e. don't use "that.save = function () {...};).

The members option is essentially a simpler version of invokers. The right-hand side of each property is evaluated as an IoC expression and assigned to the top-level component path held on the left-hand side. Unlike invokers, methods are evaluated only once during component construction.

fluid.defaults("my.component", {
    ...
    members: {
        width: "{that}.options.width", // promotes the 'size' option to a property of the component, i.e. 'that.size'
        computeArea: "my.component.computeArea" // component method will resolve to the free function
    }
});