Class: ElementRef

capsula.ElementRef(el)

ElementRef capsule wraps (and references) an external element (object) to prepare it to participate in a hierarchy of similar elements. In other words, the ElementRef capsule provides an API around the wrapped element; an API that serves the purpose of managing hierarchical structures of elements.

ElementRef capsule wraps a single element and creates one hook and one loop, i.e. the hook and the loop that directly represent the wrapped element. The hook represents it as a parent while the loop represents it as a child in its future parent-child relationships.

Connecting hooks and loops only make sense once the element handlers functions are set using the setDefaultElementHandlers function.

Constructor

new ElementRef(el)

Creates an instance of ElementRef capsule around the given element (object).
Parameters:
Name Type Description
el Object the element to wrap
Since:
  • 0.1.0
Source:
Example

Creating a hierarchy of two elements (widgets in this case)

var divElement = document.getElementById(...); // or document.createElement('div')
var labelElement = document.getElementById(...); // or document.createElement('label')
var divCapsule = new capsula.ElementRef(divElement);
var labelCapsule = new capsula.ElementRef(labelElement);

divCapsule.hook.tie(labelCapsule.loop); // this is where the divElement becomes the parent of the labelElement

Members

Collection of Hooks

Properties:
Name Type Description
hook module:capsula.Hook A hook that represents the wrapped element (object).
Since:
  • 0.1.0
Source:

Collection of Loops

Properties:
Name Type Description
loop module:capsula.Loop A loop that represents the wrapped object (element).
Since:
  • 0.1.0
Source:

Methods

getElement() → {Object}

Returns the wrapped object (element).
Since:
  • 0.1.0
Source:
Returns:
the wrapped object (element)
Type
Object