Class: Events

Oracle® JavaScript Extension Toolkit (JET)
3.2.0

E87541-01

QuickNav

Fields

oj. Events

Version:
  • 3.2.0
Supports event system for the common model (oj.Collection and oj.Model)

Constructor

new Events()

Source:

Fields

<static> EventType :string

Properties:
Name Type Default Description
ADD string add Triggered when a model is added to a collection

The event passes these arguments to the handler:

    model: the model being added to the collection
    collection: the collection to which the model has been added
    options: any options passed in to the add call that triggered the event
ALLADDED string alladded Triggered by a collection during an add call once all models passed in have been added

The event passes these arguments to the handler:

    collection: the collection to which the models have been added
    models: the array of models that have been added
    options: any options passed in to the add call
REMOVE string remove Triggered when a model is removed from a collection

The event passes these arguments to the handler:

    model: the model being removed from the collection
    collection: the collection from which the model was removed
    options: index: the index of the model being removed
RESET string reset Triggered when a collection is reset (see oj.Collection.reset)

The event passes these arguments to the handler:

    collection: the collection being reset
    options: any options passed in to the reset call
REFRESH string refresh Triggered when a collection is refreshed (see oj.Collection.refresh)

The event passes these arguments to the handler:

    collection: the collection being refreshed
    options: any options passed in to the refresh call
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

The event passes these arguments to the handler:

    collection: the collection being sorted
    options: add: true if this sort event was triggered as the result of an add call, undefined or false if not
CHANGE string change Triggered when a model's attributes are changed. This can be the result of a clear call on a model; a property set call on a model; an unset call on a model; or the changing of properties due to the merging of models (in an add, for example)

The event passes these arguments to the handler:

    model: the model on which the change occurred
    value: for property-specific change events, the new value of the property being changed
    options: any options passed in to the call that triggered the change event. This is the second argument passed for overall change events, and the third parameter (after value) for property-specific change events.
DESTROY string destroy Triggered when a model is deleted from the data service (and thus from its Collection), due to a model destroy call

The event passes these arguments to the handler:

    model: the model being deleted
    collection: the deleted model's collection, if any
ALLREMOVED string allremoved Triggered by a collection during a remove call once all models passed in have been removed and destroyed

The event passes these arguments to the handler:

    collection: the collection from which the models have been removed
    models: the array of models that have been removed
    options: any options passed in to the remove call
REQUEST string request Triggered when a model or collection has sent a request to the data service

The event passes these arguments to the handler:

    collection or model: the collection or model triggering the request
    xhr: the xhr argument for the request
    options: any options passed as part of the request
SYNC string sync Triggered when a model or collection has been updated from the data service

The event passes these arguments to the handler:

    collection or model: the collection or model that triggered the update
    response: the response object from the data service
    options: any options passed in to the call that triggered the update
ERROR string error Triggered when a model has failed to update on the data service

The event passes these arguments to the handler:
collection or model: the collection or model that made the call that resulted in the error
xhr: the xhr argument for the failing request, if any
options: any options passed in to the call that triggered the failing request, plus the status and error as textStatus and errorThrown

INVALID string invalid Triggered on an error with data source interactions

The event passes these arguments to the handler:

    model: the model (or collection) on which the error operation happened
    xhr: the xhr involved, if relevant
    options: any options passed in to the call that triggered the invalid event
READY string ready Triggered when all pending promises from Collection API calls have been resolved

The event passes these arguments to the handler:

    collection: the collection on which the promises have been resolved
ALL string all Triggered for any of the above events

The event passes the name of the actual event and then any arguments normally passed to that event following the name

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: