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.

Skip to end of metadata
Go to start of metadata

Use free functions (namespaced accordingly) whenever possible.

In general, any code you write should be in free functions that are referenced by defaults blocks. For example, if you need to modify the class name of a DOM element in response to some event, create a free function in the namespace of your component:

my.component.applyStyle = function (elements, cssClass) {
    elements.addClass(cssClass);
};

Free functions such as these should not be called directly; they should be used as event listeners or invokers.

For example, as an event listener:

fluid.defaults("my.component", {
    gradeNames: ["fluid.viewComponent", "autoInit"],
    listeners: {
        onStyleChange: {
            listener: "my.component.applyStyle",
            args: ["{arguments}.0", "{arguments}.1"]
        },
        ...

OR as an invoker:

fluid.defaults("my.component", {
    gradeNames: ["fluid.viewComponent", "autoInit"],
    invokers: {
        applyStyle: {
            funcName: "my.component.applyStyle",
            args: ["{arguments}.0", "{arguments}.1"]
        },
        ...
  • No labels