fluid.initRendererComponent
This functionality is Sneak Peek status. This means that the APIs may change. We welcome your feedback, ideas, and code, but please use caution if you use this new functionality.
fluid.initRendererComponent(componentName, container, options)
An initialiation method that can be called as the first act of any component that uses the Infusion Renderer. This function automatically initializes the Renderer in addition to merging user options with defaults, attaching a DOM Binder to the instance, and configuring events.
fluid.initRendererComponent(componentName, container, options);
File name: RendererUtilities.js
Parameters
componentName |
(String) The unique "name" of the component, which will be used to fetch the default options from store. By recommendation, this should be the global name of the component's creator function. |
container |
(jQueryable) A specifier for the single root "container node" in the DOM which will house all the markup for this component. |
options |
(Object) The configuration options for this component |
Return Value
Object | A renderer-bearing component object. |
Options
As with any component initialization function, the options
object will be merged with any defaults found for the componentName
, and the result will be attached to the returned object. In general, options are specific to each component.
This renderer initialization function, however, recognizes certain particular options that will be used to configure the renderer. A component may wish to define defaults for some of these options. Others will be provided by the component user (e.g. model
). The renderer-specific options are:
Renderer Function Options
The fluid.initRendererComponent
initializer will create a render
function that will be attached to the that
object. The options
parameter includes an options called rendererFnOptions
that can contain options that will control the behaviour of the renderer function. The following renderer function options are supported:
Name |
Description |
Values |
Default |
---|---|---|---|
|
A function that can be used to create a list of cutpoints.NOTE that this function will only be used if the |
function |
|
|
Options that will be passed on to the prototree expander function. Note that if the |
Object |
none |
|
A flag that, if |
boolean |
|
|
Options that will be passed on to the Renderer itself. See fluid.render for more information |
Object |
none |
|
A string selector, DOM node or jQuery object containing the source template to be used for rendering by this function. |
jQueryable |
none; The |
Renderer Options
The render
function will use the Infusion Renderer to render the component. The Renderer itself can be configured using options, which can be provided using the rendererOptions
option. The following renderer options are supported:
Field |
Description |
Type |
In/Out |
---|---|---|---|
|
Perhaps the most important parameter, contains the "data model" to which value bindings expressed within the tree will be expressed. |
free |
Mostly In, but the supplied model may be written to later as a result of servicing user actions, especially if the parameter |
|
a ChangeApplier object associated with the |
|
In |
|
If set, any user modification of fields with |
|
In |
|
If set, will cause the rendered ids to be uniquified against the supplied document, rather than the current one |
|
In |
|
If set, mismatches between template and component tree will be highlighted in an unreasonable garish pink colour |
|
In |
|
This map operates in conjunction with the |
free |
In/Out |
|
Configures the lookup from (I18N) messages referenced in the component tree, to some source of a message bundle |
|
In |
|
Will construct a |
|
In |
|
Will XMLEncode the rendered markup before insertion into the document. Can be useful for debugging |
|
In |
|
This is properly a directive to the parser, rather than the renderer, but the options structure is shared. This contains a list of pairs of |
Array of |
In |
Example
// Declare defaults for the component fluid.defaults("cspace.autocomplete.popup", { selectors: { addToPanel: ".csc-autocomplete-addToPanel", authorityItem: ".csc-autocomplete-authorityItem", noMatches: ".csc-autocomplete-noMatches", matches: ".csc-autocomplete-matches", matchItem: ".csc-autocomplete-matchItem", longestMatch: ".csc-autocomplete-longestMatch", addTermTo: ".csc-autocomplete-addTermTo" }, repeatingSelectors: ["matchItem", "authorityItem"], resources: { template: { href: "html/AutocompleteAddPopup.html" } }, .... }; // Component creator function cspace.autocomplete.popup = function(container, options) { var that = fluid.initRendererComponent("cspace.autocomplete.popup", container, options); ... return that; };
This example uses fluid.initRendererComponent()
to initialize a component called cspace.autocomplete.popup
. The defaults for the component include defaults for several renderer-specific options: selectors
, repeatingSelectors
and resource
.
The that
object that is returned by the call to fluid.initRendererComponent()
will include a render()
function that can be used to render the data model provided by the implementor, using the provided selectors. The HTML file referenced by template.href
will be retrieved and stored back in the template
for use by the component.