Section DOM
Description
Extensions to DOM elements, plus other utilities for DOM traversal and modification.
Prototype's DOM extensions represent a large portion of where you'll spend
your time. Prototype adds many convenience methods to elements returned by
the $ function. For instance, you can write
$('comments').addClassName('active').show();
to get the element with the ID of comments, add a class name to it, and
show it (if it was previously hidden).
In other words, Prototype adds "instance" methods to DOM nodes. This is made possible by direct extension of the backing DOM objects (in browsers that support it) and by manual extension of individual nodes (in browsers that do not).
Namespaces
-
Abstract
-
Form.Element
Utilities for dealing with form controls in the DOM.
-
Form
Utilities for dealing with forms in the DOM.
-
document
Prototype extends the built-in
documentobject with several convenience methods related to events. -
document.viewport
The
document.viewportnamespace contains methods that return information about the viewport — the rectangle that represents the portion of a web page within view. In other words, it's the browser window minus all chrome.
Classes
-
Element
-
Event
The namespace for Prototype's event system.
-
Form.Element.EventObserver
-
Form.EventObserver
-
Abstract.EventObserver
-
Form.Observer
An
Abstract.TimedObserversubclass that watches for changes to a form. The callback is triggered when the form changes — e.g., when any of its fields' values changes, when fields are added/removed, etc.; anything that affects the serialized form of the form (seeForm.serialize). -
Form.Element.Observer
An
Abstract.TimedObserversubclass that watches for changes to a form field's value. This triggers the callback when the form field's value (according toForm.Element.getValue) changes. (Note that when the value actually changes can vary from browser to browser, particularly withselectboxes.) -
Selector
A class that queries the document for elements that match a given CSS selector.
-
Abstract.TimedObserver
An abstract DOM element observer class, subclasses of which can be used to periodically check a value and trigger a callback when the value has changed.