This is useful when jQuery custom events aren’t appropriate because there’s no DOM element involved.
This is implemented as a thin wrapper on jQuery.Callbacks().
Usage
Here’s a simple class Car that exposes the event ondrive:
A consumer of Car could observe the event:
We can also customize the event object that is passed to observers:
The event object passed to handlers of jQuery.CustomEvent is a jQuery.Event, and is
also returned from jQuery.CustomEvent.fire(). This is useful if you want to use jQuery.Event’s methods,
such as preventDefault() and isDefaultPrevented() to allow observers to influence the behavior of the
object.