The ControlFramework
interface specifies those lifecycle functions that are necessary
for a control implementation to be managed by the Control Framework.
Methods
bind(control Element)
Binds the renderer to the DOM and attaches any event listeners to the control.
Parameters:
Name | Type | Description |
---|---|---|
controlElement |
HTMLElement | The DOM element representing the renderer |
create Html(field Values, class Name) → {HtmlEl ement|Document Fragment}
Returns an HTMLElement (or DocumentFragment) that defines this element.
This is the first of two steps required to bind a renderer to its corresponding HTML element. In fact, there are two ways of binding a renderer:
- The simplest way is to use the
module:ct-element/RendererFramework#getElement
helper method — this invokescreateHtml()
andmodule:ct-element/RendererFramework#bind
on your behalf. - A more performant mechanism for components that contain large numbers of renderers is to use
invoke
module:ct-element/RendererFramework#createHtml
andmodule:ct-element/RendererFramework#bind
yourself, so that the entire DOM strucutre for all renderers can be created using a single use call toappendChild
, allowing significant performance gains to be achieved.
This method must be called after the FieldModel
has been set using
FieldModel.setFieldModel()
. If the FieldModel
is populated with
some initial data for this renderer, then the HTML fragment returned will also contain that value, obviating
the need for an call to module:ct-element/Renderer#setValue
afterwards.
Parameters:
Name | Type | Description |
---|---|---|
fieldValues |
Map | The field values |
className |
string | The HTML class attribute (a space separated list) |
Returns:
The HTML fragment.
- Type
-
Html
Element | Document Fragment
finalize()
Releases any renderer resources and resets its state.
get All Field Names() → {Array}
Returns a complete list of all field names that the renderer depends on.
Returns:
The field names.
- Type
- Array
get Element() → {Element}
Returns the element that this renderer is associated with.
If the renderer binding was not performed manually using module:ct-element/RendererFramework#createHtml
and module:ct-element/RendererFramework#bind
,
then this helper method will do this automatically on your behalf.
- See:
-
- module:ct-element/RendererFramework#createHTML
- module:ct-element/RendererFramework#bind
- module:ct-element/RendererFramework#unbind
Returns:
The element associated with this renderer.
- Type
- Element
get Primary Field Names() → {Array.< string>}
Returns a list of primary fields.
Returns:
The field names.
- Type
-
Array
.<string>
get Serial Id() → {string}
Returns the serial id of the renderer instance.
Returns:
The renderer serial id.
- Type
- string
initialize(initial Field Values)
Initializes the renderer and sets its state according to the supplied field values.
Parameters:
Name | Type | Description |
---|---|---|
initialFieldValues |
Map | The initial field values |
is Bound() → {boolean}
Returns true if the renderer has been bound to the DOM.
Returns:
True if the renderer has been bound to the DOM, or false otherwise.
- Type
- boolean
set Name(name)
Sets the renderer's name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The renderer's name. |
set Namespace(namespace)
Sets the renderer's namespace.
Parameters:
Name | Type | Description |
---|---|---|
namespace |
string | The renderer's namespace. |
unbind()
Unbinds the renderer from the DOM and detaches any event listeners to the control.