Binding

Binding

While a Model defines the outlook of a component, a Binding defines its behavior.

Constructor

new Binding(eventListeneropt)

Source:
Parameters:
Name Type Attributes Default Description
eventListener EventListener <optional>
new EventListener(new Observable())

Members

window :Window

Source:
Type:
  • Window

document :Document

Source:
Type:
  • Document

identifier :object

Source:

Access any child Model identified with the "identifier" property. Any identifier returns a Binding instance

Type:
  • object

elements :object

Source:

This is a shortcut to this.identifier["foo"].element Access any child Model's element identified with the "identifier" property. Any identifier returns an Element

Type:
  • object

parent :Binding

Source:

Parent Binding

Type:

root :Element

Source:
Type:
  • Element

model :Model

Source:
Type:

children :Array.<ChildBinding>

Source:

List of child Binding

Type:
  • Array.<ChildBinding>

_observables :Map

Source:

Observable register

Type:
  • Map

Methods

listen(target, eventName, callback, unshiftopt) → {Listener}

Source:

Alias for Observable.listen, the listeners are also stored for later removal.

Example
binding.listen(observable, "myEvent", message => console.log(message))
Parameters:
Name Type Attributes Default Description
target *
eventName string
callback function
unshift boolean <optional>
false
Returns:
Type
Listener

emit(target)

Source:
Parameters:
Name Type Description
target *

run(model, runParameters, identifier) → {Element}

Source:

Alias for Core.run, except that the target is pre-configured to be the current Binding's root Element. Allows identification and hierarchization of Models inside the current Binding.

Example
binding.run(Model, { binding: new Binding() })
Parameters:
Name Type Description
model Model
runParameters RunParameters
identifier str
Returns:
Type
Element

remove()

Source:

Remove the associated Model and all its children from the DOM and clean up any DOM Event or Observable listeners associated with them.

addEventListener(target, type, listener, options)

Source:

Store an DOM event listener for later removal.

It can be used to store event listeners on foreign Element such as Window.

Parameters:
Name Type Description
target Element
type string
listener method
options object

(abstract) onCreated()

Source:

This hook is called after the Element is created but before the Element is connected to the DOM

(abstract) onConnected()

Source:

This hook is called after the Element is created and is connected to the DOM

Type Definitions

ChildBinding

Source:
Properties:
Name Type Attributes Description
childModel.model ElementDefinition
childModel.binding Binding
childModel.identifier str <optional>
Type:
  • object