Document

Document is a dom-wrapper designed to work with dom-documents, basically it is an API to work with events, plus the onReady method to track the document-ready event.

Document Ready

The dom-ready event in RightJS is simply called ready and you can assign a listener to it in any of the standard ways:

$(document).onReady(function() {...});
$(document).on('ready', function() {...});

Methods

listeners, observes, on, onReady, stopObserving

top ↑listeners

listeners() -> Array of functions
listeners(String name) -> Array of functions

Description

Returns a list of document event listeners which can optionally be narrowed down by an event name scope.

Example

var func = function() {};

$(document).on('click', func);

$(document).listeners(); // -> [func]
$(document).listeners('click'); // -> [func]
$(document).listeners('mouseover'); // -> []

top ↑observes

observes(Function listener) -> boolean
observes(String name[, Function listener]) -> boolean

Description

Checks if the given listener observers the document events. You can do either a general check or against a specific event name.

Example

var func = function() {};

$(document).on('click', func);

$(document).observes(func); // -> true
$(document).observes('mouseover', func); // -> false

top ↑on

on(String name, Function callback[, arguments, ...]) -> Document self

Description

The standard listeners attachment method

Example

$(document).on('ready', function() {....});

top ↑onReady

onReady(Function callback[, arguments[, ....]]) -> Document self

Description

A shortcut method for on('ready', ...)

Example

$(document).onReady(function() {....});

top ↑stopObserving

stopObserving(Function listener) -> Document self
stopObserving(String name[, listener]) -> Document self

Description

Unsubscribes the event listener. This can be done globally for a particular event name, for some particular listener or for some particular listener and event name.

Example

var listener = function() {};

$(document).on('click', listener);

$(document).stopObserving('click');

$(document).stopObserving(listner);

$(document).stopObserving('click', listner);