new DOMListener(el)
Create a new DOMListener
Parameters:
Name | Type | Description |
---|---|---|
el |
Object | String | The DOM Node or DOM selector string to use for this element |
Methods
-
off( [event] [, callback] [, options])
-
Unsubscribe one or more listeners from the element.
Parameters:
Name Type Argument Description event
String <optional>
The event to remove. If none is specified, all events will be removed. callback
function <optional>
The callback to remove. If none is specified, all callbacks for the specified event will be removed. options
Object <optional>
The options for the event listener. See the options object of the DOM's addEventListener method. Returns:
Returns the DOM Listener object.- Type
- Object
-
on(event, callback [, options])
-
Subscribe a callback to an event
Parameters:
Name Type Argument Description event
String The name of the event to subscribe to. Must be a valid event type. callback
function The function to invoke when the event is fired options
Object <optional>
The options for the event listener. See the options object of the DOM's addEventListener method. Returns:
Returns the DOM Listener object- Type
- Object
-
once(event, callback)
-
Subscribe a callback to an event to fire exactly once. After the callback is invoked, it will be removed from the listeners.
Parameters:
Name Type Description event
String The name of the event to subscribe to. Must be a valid event type. callback
function The function to invoke when the event is fired. Returns:
Returns the DOM Listener object- Type
- Object