new ChildElement(widget, name, config)

Creates a HTMLElement as a child for a widget. Is used to simplify widget definitions. E.g. the tiny marker used to display the back-end value is a simple DIV added using TK.ChildElement. The generic element is a DIV added to TK.Widget.element with the class toolkit-[name]. Default creating and adding can be overwritten with custom callback functions.

Name Type Description
widget TK.Widget

The TK.Widget to add the TK.ChildElement to.

name string

The identifier of the element. It will be prefixed by an underscore TK.Widget["_" +].

config object

The configuration of the child element.

Name Type Attributes Default Description boolean <optional>

Show/hide the child element on initialization.

config.option string <optional>

A custom option of the parent widget to determine the visibility of the child element. If this is null, TK.Widget.options["show_"+] is used to toggle its visibility. The child element is visible, if this options is !== false.

config.display_check function <optional>

A function overriding the generic show_option behavior. If set, this function is called with the value of show_option as argument as soon as it gets set and is supposed to return a boolean defining the visibility of the element.

config.append function <optional>

A function overriding the generic append mechanism. If not null, this function is supposed to take care of adding the child element to the parent widgets DOM.

config.create function <optional>

A function overriding the generic creation mechanism. If not null, this function is supposed to create and return a DOM element to be added to the parent widget.

config.toggle_class boolean <optional>

Defines if the parent widget receives the class toolkit-has-[name] as soon as the child element is shown.

config.draw_options array <optional>

A list of options of the parent widget which are supposed to trigger a check if the element has to be added or removed.

config.draw function <optional>

A function to be called on redraw.