Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Div
classfloatRight
Panel
borderColor#ccc
bgColor#fff
titleOn This Page
borderStylesolid
Table of Contents
maxLevel3
minLevel2
exclude.*Downward*distributeOptions and IoCSS: Downward-Matching CSS-Like Context Selectors For Options Forwarding

distributeOptions and IoCSS: Downward-Matching CSS-Like Context Selectors For Options Forwarding

...

Name

Description

target

(Required) An IoC expression describing the location in the component tree where the options are to be set. The "context" part of this expression will usually consist of an IoCSS selector (see below for format). However, it may also in specialised cases consist of a standard "upwards" IoC context expression, indicating that options are to be distributed to a parent component (this is only meaningful in the case the parent has not finished instantiating).

source

(Mutually exclusive with record) A reference  An IoC expression into the options structure of the source component, referencing what to copy to the target. If target's context is an IoCSS selector, the source must be the current component, i.e. that.

record 

(Mutually exclusive with source) A record of options to set at the target.

removeSource(Only possible if source is used) true/false: If true, the source options block is removed from its original site in the options structure when it is forwarded to the target.

exclusions

(Only possible if source is used) A list of EL paths into the source material which should not be forwarded. Whether or not removeSource is used, these will be retained in their original position in the source component's options.

...

Code Block
javascript
javascript
fluid.defaults("fluid.tests.uploader", {
    gradeNames: ["fluid.littleComponent", "autoInit"],
    components: {
        uploaderContext: {
            type: "fluid.progressiveCheckerForComponent",
            options: {componentName: "fluid.tests.uploader"}
        },
        uploaderImpl: {
            type: "fluid.tests.uploaderImpl"
        }
    },
    distributeOptions: [{
        target: "{that > uploaderImpl}.options" // Target a directly nested component matching the context "uploaderImpl"
        source: "{that}.options",               // Distribute ALL of our options there, except exclusions:
        exclusions: ["components.uploaderContext", "components.uploaderImpl"], // options targetted directly at these subcomponents are left undisturbed in place

    }],
    progressiveCheckerOptions: {
        checks: [
            {
  
             feature: "{fluid.test}",
   
            contextName: "fluid.uploader.html5"
 
          }
        ]
    }
});

Example: record

Code Block
javascript
javascript
fluid.defaults("fluid.moduleLayoutHandler", {
    gradeNames: ["fluid.layoutHandler", "autoInit"],
    ...
    distributeOptions: {
        target: "{reorderer}.options", // unusual: upward-matching selector distributes options back to parent before instantiation ends
        record: {
            selectors: {
                movables: {
                    expander: {
                        func: "{that}.makeComputeModules",
                        args: [false],
                    }
                },
                dropTargets: {
                    expander: {
                        func: "{that}.makeComputeModules",
                        args: [false],
                    }
                },
                selectables: {
                    expander: {
                        func: "{that}.makeComputeModules",
                        args: [true],
                    }
                }
            }
        }
    }
});