Mixin: Events

Oracle® Fusion Middleware Oracle JavaScript Extension Toolkit (JET)
12c (12.1.4)

E54107-01

QuickNav

oj. Events

Source:

Fields

<static> EventType :string

Properties:
Name Type Default Description
ADD string add Triggered when a model is added to a collection
REMOVE string remove Triggered when a model is removed from a collection
RESET string reset Triggered when a collection is reset (see oj.Collection.reset)
REFRESH string refresh Triggered when a collection is refreshed (see oj.Collection.refresh)
SORT string sort Triggered when a collection is sorted. If the second argument to the callback is set (options) and 'add' is true, it means this sort event was triggered as a result of an add
CHANGE string change Triggered when a model's attributes are changed
DESTROY string destroy Triggered when a model is deleted from the data service (and thus from its Collection)
REQUEST string request Triggered when a model or collection has sent a request to the data service
SYNC string sync Triggered when a model or collection has been updated from the data service
ERROR string error Triggered when a model has failed to update on the data service
INVALID string invalid Triggered when a model being saved has been invalidated by the caller
ALL string all Triggered for any of the above events
Source:

Methods

<static> listenTo(otherObj, eventType, callback)

Add an event handler for an event type to a second model or collection object ("otherObj"), but track it on the called object.
Parameters:
Name Type Description
otherObj Object Model or collection object on which to add this event handler.
eventType String Types of event handlers to add (may be a single event type or a space-delimited set of event types).
callback function(String, Object) User's event handler callback function (called with the eventType and model or collection object as parameters--the context will be the model or collection unless specified by context, below).
Source:

<static> listenToOnce(otherObj, eventType, callback)

Add an event handler for an event type to a second model or collection object ("otherObj"), but track it on the called object. Only fire once.
Parameters:
Name Type Description
otherObj Object Model or collection object on which to add this event handler.
eventType String Types of event handlers to add (may be a single event type or a space-delimited set of event types).
callback function(String, Object) User's event handler callback function (called with the eventType and model or collection object as parameters--the context will be the model or collection unless specified by context, below).
Source:

<static> off(eventType, callback, context)

Remove an event handler for an event type from the model or collection object.
Parameters:
Name Type Argument Description
eventType String | Object <optional>
Types of event handlers to remove (may be a single event type, a space-delimited set of event types, or a map of events to callbacks). If omitted, remove all event handlers.
callback function(String, Object) <optional>
If provided, remove handlers only for eventType events with the given callback function.
context Object <optional>
If provided, remove handlers only for eventType events with the given callback function and context object.
Source:

<static> on(eventType, callback, context)

Add an event handler for an event type to the model or collection object.
Parameters:
Name Type Argument Description
eventType String | Object Types of event handlers to add (may be a single event type, a space-delimited set of event types, or an object mapping events to callbacks).
callback function(String, Object) User's event handler callback function (called with the eventType and model or collection object as parameters--the context will be the model or collection unless specified by context, below).
context Object <optional>
A context for the event
Source:

<static> once(eventType, callback, context)

Add an event handler for an event type to the model or collection object, but only fire it once, then remove it from the list of handlers.
Parameters:
Name Type Argument Description
eventType String Types of event handlers to add (may be a single event type or a space-delimited set of event types).
callback function(String, Object) User's event handler callback function (called with the eventType and model or collection object as parameters--the context will be the model or collection unless specified by context, below).
context Object <optional>
A context for the event
Source:

<static> stopListening(otherObj, eventType, callback)

Remove event handlers from a model or collection object. If the arguments are omitted, removes all event handlers from the model or collection.
Parameters:
Name Type Argument Description
otherObj Object <optional>
If specified, remove event handlers that target otherObj from this model or collection.
eventType String <optional>
If specified, remove the event handlers for the given event types from this model or collection
callback function(String, Object) <optional>
If specified, remove event handlers that call the given user callback function from this model or collection
Source:

<static> trigger(eventType)

Fire the given event type(s) for all registered handlers.
Parameters:
Name Type Description
eventType String Types of event handlers to fire (may be a single event type or a space-delimited set of event types).
Source: