TemplateToBinding
Describes either:
- a binding to an
Observable, - or a native DOM event binding.
It is created by the to method.
Properties
attribute : stringreadonlyinheritedmodule:ui/template~TemplateToBinding#attributeThe name of the observed attribute.
callback : ( value: any, node: Node ) => TemplateSimpleValue | undefinedreadonlyinheritedmodule:ui/template~TemplateToBinding#callbackA custom function to process the value of the
attribute.module:ui/template~TemplateToBinding#emitterAn
Emitterused by the binding to:- listen to the attribute change in the
observable, - or listen to the event in the DOM.
- listen to the attribute change in the
eventNameOrFunction : string | ( domEvent: Event ) => voidreadonlymodule:ui/template~TemplateToBinding#eventNameOrFunctionobservable : Observablereadonlyinheritedmodule:ui/template~TemplateToBinding#observableAn observable instance of the binding. It either:
- provides the attribute with the value,
- or passes the event when a corresponding DOM event is fired.
Methods
constructor( def )module:ui/template~TemplateToBinding#constructoractivateAttributeListener( schema, updater, data ) → () => voidinheritedmodule:ui/template~TemplateToBinding#activateAttributeListenerActivates the listener which waits for changes of the
attributeinobservable, then updates the DOM with the aggregated value ofTemplateValueSchema.Parameters
schema : Array<TemplateSimpleValue | TemplateBinding>A full schema to generate an attribute or text in the DOM.
updater : UpdaterA DOM updater function used to update the native DOM attribute or text.
data : RenderDataRendering data.
Returns
() => voidA function to sever the listener binding.
activateDomEventListener( domEvtName, domSelector, data = { data.node } ) → () => voidmodule:ui/template~TemplateToBinding#activateDomEventListenerActivates the listener for the native DOM event, which when fired, is propagated by the
emitter.Parameters
domEvtName : stringThe name of the native DOM event.
domSelector : stringThe selector in the DOM to filter delegated events.
data : objectRendering data.
Propertiesdata.node : any
Returns
() => voidA function to sever the listener binding.
getValue( node ) → TemplateSimpleValueinheritedmodule:ui/template~TemplateToBinding#getValueReturns the value of the binding. It is the value of the
attributeinobservable. The value may be processed by thecallback, if such has been passed to the binding.Parameters
node : NodeA native DOM node, passed to the custom
callback.
Returns
TemplateSimpleValueThe value of
attributeinobservable.