Class: ComponentBinding

Oracle® JavaScript Extension Toolkit (JET)
17.1.0

G12196-01

Since:
  • 1.0
Module:
  • ojknockout

QuickNav

Description

JQueryUI component binding for Knockout.js.


Usage

For additional information visit:


See:
To create a custom binding, use ComponentBinding.create(). Using prototypal inheritance to extend ComponentBinding is not supported.
See:

Methods

(static) create(name, options) : {ComponentBinding}

Creates a binding instance and registers it with Knockout.js. Note that in order to use this method you have to map ojknockout to ojknockout-legacy in your require.config object.
Parameters:
Name Type Argument Description
name string | Array.<string> the name of the binding or an array of strings in case the binding needs to be registered under several names
options Object | string <optional>
<nullable>
property object with the following fields:
  • {string} 'componentName' - name of the component Not specifying this parameter indicates that the binding should use the 'component' attribute on itself to determine the constructor name
  • {Function} 'afterCreate'- a callback invoked after the component instance has been created. The function will receive the following parameters:
    • {Element} element - DOM element associated with this binding
    • {Function} widgetConstructor - constructor for the JQueryUI widget created by this binding. The constructor is already bound to the associated JQuery element
    • {Function} valueAccessor - a JavaScript function that you can call to get a map of current binding attributes
    • {Object} allBindings - a JavaScript object that you can use to access all the model values bound to this DOM element
    • {Object} bindingContext - an object that holds the binding context available to this element's bindings. This object includes special properties including $parent, $parents, and $root that can be used to access data that is bound against ancestors of this context
  • {Function} 'beforeDestroy'- a callback invoked before the component instance is detroyed The function will receive the same parameters as the 'afterCreate' callback above.
When this parameter is specified as a string, it will be interpreted as a single 'componentName' option
Deprecated:
Since Description
16.0.0 Any code relying on this functionality should be migrated to using the custom element equivalents.
Returns:

binding instance

Type
ComponentBinding

(static) deliverChanges : {void}

Delivers all accumulated component changes across all instances of this binding. Calling this method is optional - the changes will be delivered after a 1ms timeout if this method is never invoked. However, you may call this method to speed up component updates when the aplication code is done updating the view models.
Returns:
Type
void

(static) getDefaultInstance : {ComponentBinding}

Retrieves the default component binding instance registered with Knockout.js. Note that in order to use this method you have to map ojknockout to ojknockout-legacy in your require.config object.
Deprecated:
Since Description
16.0.0 Any code relying on this functionality should be migrated to using the custom element equivalents.
Returns:

default binding instance

Type
ComponentBinding

setupManagedAttributes(opts) : {void}

Sets up custom handling for attributes that will be managed by this binding instance. Note that in order to use this method you have to map ojknockout to ojknockout-legacy in your require.config object.
Parameters:
Name Type Description
opts Object property object with the following fields:
  • 'attributes' - string array of attribue names
  • {Function} 'init' - a function called when a managed attribute is initialized. The function will receive the following parameters:
    • {string} name - attribute name
    • {Object} value - attribute value
    • {Element} element - DOM element where this binding is being attached
    • {Function} widgetConstructor - constructor for the JQueryUI widget created by this binding. The constructor is already bound to the associated JQuery element
    • {Function} valueAccessor - a JavaScript function that you can call to get a map of current binding attributes
    • {Object} allBindings - a JavaScript object that you can use to access all the model values bound to this DOM element
    • {Object} bindingContext - an object that holds the binding context available to this element's bindings. This object includes special properties including $parent, $parents, and $root that can be used to access data that is bound against ancestors of this context
    The optional return value of the function is a name-to-value map of properties that should be set on the component
  • {Function} 'update' - a function called when a managed attribute is updated. The function will receive the same parameters as the 'init' callback above. The optional return value of the function is a name-to-value map of properties that should be set on the component at the time when other accumulated changes are delivered
  • {Function} 'afterCreate'- a callback invoked after the component instance has been created. The function will receive the following parameters:
    • {string} name - attribute name
    • {Element} element - DOM element associated with this binding
    • {Function} widgetConstructor - constructor for the JQueryUI widget created by this binding. The constructor is already bound to the associated JQuery element
    • {Function} valueAccessor - a JavaScript function that you can call to get a map of current binding attributes
    • {Object} allBindings - a JavaScript object that you can use to access all the model values bound to this DOM element
    • {Object} bindingContext - an object that holds the binding context available to this element's bindings. This object includes special properties including $parent, $parents, and $root that can be used to access data that is bound against ancestors of this context
  • {string} 'for' (optional) - a string representing component type or constructor name restricting the applicability of these managed attributes
  • {Array.} 'use' (optional) - an string array of component types whose managed attribute behavior should be used for the component type specified with the 'for' attribute
  • {Function} 'beforeDestroy'- a callback invoked before the component instance is detroyed The function will receive the same parameters as the 'afterCreate' callback above.
Deprecated:
Since Description
16.0.0 Any code relying on this functionality should be migrated to using the custom element equivalents.
Returns:
Type
void