Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 1.73 KB

CUSTOM_TRIGGERS.md

File metadata and controls

69 lines (54 loc) · 1.73 KB

Observe.js - Binding Options - Custom Triggers:

Below is a list of all the custom triggers supported in the "data-observe-js" binding attribute for DOM elements. These options are also supported when calling the public function "watch()".

When Changes Are Detected:

options.events.onChange( oldValue, newValue ):

Fires when a change has been detected in an object.
Parameter: oldValue: 'object' - The old value for the object.
Parameter: newValue: 'object' - The new value for the object.

options.events.onPropertyChange( propertyName, oldValue, newValue ):

Fires when a change has been detected in an object (states which property changed).
Parameter: propertyName: 'string' - The name of the property that has been changed.
Parameter: oldValue: 'object' - The old value.
Parameter: newValue: 'object' - The new value.

options.events.onCancel( id ):

Fires when a watch has been cancelled.
Parameter: id: 'string' - The ID of the watch that has been cancelled.

options.events.onRemove( id ):

Fires when a DOM element is no longer available in the DOM.
Parameter: id: 'string' - The ID of the DOM element.

options.events.onStart( originalValue ):

Fires when a watch is started.
Parameter: id: 'object' - The object that the watch as started for.

Binding Example:

<div data-observe-js="{ 'events': { 'onChange': yourCustomJsFunction } }">
    Your HTML.
</div>

"watch()" Example:

<script> 
    var version = $observe.watch( yourObject, {
        events: {
            onChange: yourCustomJsFunction
        }
    } );
</script>