Documentation
Dojo¶
Contents
The dojo directory contains three categories of modules:
- dojo.js - the bootstrap
- dojo/_base - basic functionality historically pulled in as part of dojo.js, and historically existing directly under the dojo namespace
- “dojo core” - more advanced functionality under a sub-namespace under dojo like dojo.dnd
Each category is described in detail below.
dojo.js¶
This file provides the bootstrap for loading other modules, in particular the require() function, previously known as dojo.require().
See the loader documentation for details.
For backwards-compatibility, when dojo.js is included without the async:false configuration flag, all the symbols in dojo/_base are implicitly loaded.
dojo/_base¶
The dojo/_base directory contains modules with basic functionality, such as array operations. Typically, if a function or class exists within the dojo namespace directly (eg: dojo.forEach()) then it is defined in dojo/_base.
However, note that the modules in dojo/_base are being phased out in favor of top level modules in the dojo/ directory. The dojo/_base files will be maintained until the 2.0 release. See details below for replacement modules.
Configuring Dojo (dojo/_base/config)¶
dojoConfig (dojo/_base/config)
Possibility to override certain global settings that control how the framework operates
Array utilities (dojo/_base/array)¶
Details on dojo.every, dojo.filter, dojo.forEach, dojo.indexOf, dojo.lastIndexOf, dojo.map, and dojo.some. See the Array QuickStart for an overview.
-
Invokes a callback function for every item in array
-
Applies a callback to each element of arr and returns an Array with the results
-
Iterate over an array, escaping when the callback returns true for some logic check.
-
Iterate over an array, escaping when the callback returns false for some logic check.
-
Iterate over an array, reducing the array based on the callback return.
-
Find the index of some element in an Array.
-
- NodeList.indexOf, NodeList.lastIndexOf, NodeList.forEach, NodeList.every, NodeList.some, NodeList.concat, NodeList.map, NodeList.filter, NodeList.at
Language Utilities (dojo/_base/lang)¶
-
Function that generates a wrapper function that ensures a function that will only ever execute in a defined scope.
-
Function that generates a wrapper function that ensures a function will only ever execute globally.
-
Clones objects (including DOM nodes) and all children.
-
Returns a new object which “looks” to obj for properties which it does not have a value for.
-
Checks if the parameter is a String
-
Checks if the parameter is an Array
-
Checks if the parameter is a Function
-
Checks if the parameter is an Object
-
Checks if the parameter is like an Array
-
Checks if the parameter is a built-in function
-
Trim whitespace from a String
-
Simple templates with parameterized substitutions.
-
Mixes one object into another. Can be used as a shallow copy
-
Get a property from a dot-separated string, such as “A.B.C”
-
Set a property from a dot-separated string, such as “A.B.C”
-
Determine if an object supports a given method
HTML Utility (dojo/_base/html)¶
The dojo/_base/html module contains basic DOM & HTML handling functions for backward compatibility purpose.
New code should use the dojo/dom* modules (see “Dojo core” section below for details).
Deferred Utility (dojo/_base/Deferred)¶
-
Communication between asynchronous calls
Kernel (dojo/_base/kernel)¶
from 1.7 + dojo/_base/kernel module collects following part of dojo APIs
-
Log a debug message to indicate that a behavior has been deprecated
-
Evaluate some string of JavaScript
-
A string containing the current locale as defined by Dojo
-
Returns a URL relative to a module
-
The current version number of Dojo
Window (dojo/_base/window)¶
from 1.7 + dojo/_base/window module collects following part of dojo APIs
-
Alias for the current document.
-
Return the body element of the document
-
Changes the behavior of many core Dojo functions that deal with namespace and DOM lookup
-
Call callback with globalObject as dojo.global and globalObject.document as dojo.doc
-
Call callback with documentObject as dojo.doc
Effects (dojo/_base/fx)¶
-
The workhorse of most dojo.fx animations. Used for animating CSS properties
-
1.4+ previously dojo._Animation, the class behind all dojo.fx
-
Shorthand version of animateProperty using positional arguments
Connect (dojo/_base/connect)¶
This module provides event handling for DOM nodes, and AOP for functions. However, it is superseded by the dojo/on, dojo/aspect, and dojo/topic modules, which should be used for new code.
The methods defined in this module are:
-
Connects events to methods
-
Disconnects methods from linked topics
-
Linked a listener to a named topic
-
Remove a topic listener
-
Publish an event to all subscribers of a topic
-
Ensure that every time an event is called, a message is published on the topic.
NodeList (dojo/_base/NodeList)¶
-
Connects events to every node in the list, like dojo.connect
-
Common event names mapped as functions on a NodeList - eg: .onclick(function(){})
Event (dojo/_base/event)¶
The dojo/_base/event module defines dojo DOM event API. See the dojo/_base/connect section above.
Document Lifecycle - Unload (dojo/_base/unload)¶
-
Call functions when the page unloads
-
Call functions when window.onunload fires
-
Signal fired by impending window destruction
Ajax / XHR (dojo/_base/xhr)¶
-
1.4+ Pre-defined XHR content handlers, and an extension point to add your own custom handling.
-
Core for all xhr* verbs, eg: xhrPost, getGet
Package System (defined in dojo/_base/loader)¶
This module is defining deprecated symbols for loading. See the loader documentation for details on new replacement API’s.
-
Maps module name to a path
-
Loads a Javascript module from the appropriate URI
JSON Tools (dojo/_base/json)¶
-
Parses a JSON string to return a JavaScript object
-
Returns a JSON serialization of an object
Objects / OO Tool (dojo/_base/declare)¶
dojo.declare (dojo/_base/declare)
Creates a constructor using a compact notation for inheritance and prototype extension
Colors¶
-
Color object and utility functions to handle colors. Details on
dojo.colorFromArray
dojo.colorFromHex
dojo.colorFromString
dojo.colorFromRgb.
Miscellaneous Base¶
-
Alias for the global scope
-
A collection of key constants.
-
dojo._Url is used to manage the url object.
-
dojo/_base/sniff is introduced in dojo 1.7 as the browser detection utility.
Dojo Core¶
If the function or class exists beneath the dojo namespace (eg: dojo.dnd.Mover), it is defined in “dojo core” and you will need to require the appropriate module (eg: dojo.require("dojo.dnd.Mover");) to use it.
DOM (dojo/dom*)¶
from 1.7 + dojo/dom module collects following part of dojo APIs
-
Select a DOM node by ‘id’.
dojo.isDescendant
dojo.setSelectable
Manipulation (dojo/dom-construct)
dojo.toDom
Instantiates an HTML fragment returning the corresponding DOM.
-
Creates a dom node with optional values and placement
-
Place DOM nodes relative to others
-
Destroy a DOM element
-
Empty the contents of a DOM element
Attributes (dojo/dom-attr)
-
Modifying DOM node attributes
-
Gets an attribute on an HTML element.
-
Sets an attribute on an HTML element.
-
Returns true if the requested attribute is specified on the given element, and false otherwise.
-
Removes an attribute from an HTML element.
-
Returns an effective value of a property or an attribute.
-
Form (dojo/dom-form)
-
Serialize a form field to a JavaScript object.
-
Create an object from an form node
-
Serialize a form node to a JavaScript object.
-
Returns a URL-encoded string representing the form passed as either a node or string ID identifying the form to serialize
-
Styles (dojo/dom-style)
-
A getter/setter for styles on a DOM node
-
Return a cacheable object of all computed styles for a node
-
Accesses styles on a node.
-
Sets styles on a node.
-
Class (dojo/dom-class)
-
Returns a boolean depending on whether or not a node has a passed class string.
-
Adds a CSS class to a node.
-
Removes a class from a Node.
-
Toggles a className (or now in 1.4 an array of classNames).
-
Replaces one or more classes on a node if not present. Operates more quickly than calling dojo.removeClass and dojo.addClass
-
Geometry (dojo/dom-geometry)
-
Getter for the coordinates (relative to parent and absolute) of a DOM node. Deprecated in Dojo 1.4.
-
Getter for the border-box x/y coordinates and size of a DOM node.
-
Getter/setter for the margin-box of node
-
Getter/setter for the content-box of node
-
Get an object that encodes the width, height, left and top positions of the node’s margin box.
-
Sets the size of the node’s margin box and placement (left/top), irrespective of box model.
-
Get an object that encodes the width, height, left and top positions of the node’s content box, irrespective of the current box model.
-
Sets the size of the node’s contents, irrespective of margins, padding, or borders.
-
Property (dojo/dom-prop)
-
Gets or sets a property on an HTML element.
-
Gets a property on an HTML element.
-
Sets a property on an HTML element.
-
IO-Query (dojo/io-query)¶
-
Takes a name/value mapping object and returns a string representing a URL-encoded version of that object.
-
Create an object representing a de-serialized query section of a URL. Query keys with multiple values are returned in an array.
Robot (dojo/robot & dojo/robotx)¶
-
Users who use doh+dojo get the added convenience of dojo.mouseMoveAt instead of computing the absolute coordinates of their elements themselves
-
Loads an external app into an iframe and points dojo.doc to the iframe document, allowing the robot to control it
Document Lifecycle - Onload (dojo/ready)¶
-
Call functions after the DOM has finished loading and widgets declared in markup have been instantiated
AJAX I/O transports (dojo/io/*)¶
-
Sends an AJAX I/O call using an IFrame
-
Sends a JSONP request using a script tag
AJAX RPC transports (dojo/rpc/*)¶
-
Communicate via Remote Procedure Calls (RPC) with Backend Servers
-
Generic JSONP service
-
JSON RPC service
-
RPC service class
Query (dojo/query)¶
-
The swiss army knife of DOM node manipulation in Dojo.
NodeList (dojo/NodeList-*)¶
-
A class to handle a list of DOM nodes. Most commonly returned from a dojo.query call.
-
Create classes out of each node in the list
-
Adds a .data() and .removeData() API to dojo.query operations
-
Adds dojo.fx animation support to dojo.query()
-
Adds a chainable html method to dojo.query()
-
1.4+ Method extensions to dojo.NodeList/dojo.query() that manipulate HTML.
-
1.4+ Method extensions to dojo.NodeList/dojo.query() for traversing the DOM.
Browser’s History (dojo/back & dojo/hash)¶
Data (dojo/data)¶
Store (dojo/store)¶
-
1.6+ Dojo Store is an uniform interface for the access and manipulation of stored data that will eventually replace dojo.data
-
A data access interface for in memory storage
-
A data access interface for a RESTful service providing JSON data
-
A wrapper for data stores that are observable
-
A wrapper for data stores that are cacheable
-
Cache (dojo/cache)¶
-
1.4+ A mechanism to cache inline text.
Date (dojo/date)¶
-
Date manipulation utilities
dojo.date.locale
Offers a library of localization methods to format and parse dates and times
dojo.date.locale.addCustomFormats
Adds a reference to a bundle containing localized custom formats to be used by date/time formatting and parsing routines.
-
Formats a Date object as a String, using locale-specific settings or custom patterns.
-
Used to get localized strings from dojo.cldr for day or month names.
-
Determines if the date falls on a weekend, according to local custom.
-
Converts a properly formatted string to a primitive Date object, using locale-specific settings.
-
Builds the regular needed to parse a localized date
DND (dojo/dnd)¶
-
Drag and Drop
Miscellaneous Core¶
-
A registry to make contextual calling/searching easier
-
Utility for unobtrusive/progressive event binding, DOM traversal, and manipulation
-
Get and set named properties in conjunction with the ability to monitor these properties for changes
-
Provides aspect oriented programming facilities to attach additional functionality to existing methods
-
A Common Locale Data Repository (CLDR) implementation
-
CSS color manipulation functions
-
Simple HTTP cookie manipulation
-
Localized formatting and parsing routines for currency data
-
Event handling for a group of Deferred objects
-
Effects library on top of Base animations
-
Google Gears
-
Inserting contents in HTML nodes
-
Utility classes to enable loading of resources for internationalization
dojo.jaxer
-
Localized formatting and parsing methods for number data
-
The Dom/Widget parsing package
-
Regular expressions and Builder resources
-
String utilities for Dojo
-
Provides extension events for hovering and mouse button utility functions
-
Provides normalized event listening and event dispatching functionality
-
Provides standardized touch events
-
Loads a Dojo module, by name