Skip to Content | Skip to Navigation


Dojo

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)

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.

  • dojo.forEach

    Invokes a callback function for every item in array

  • dojo.map

    Applies a callback to each element of arr and returns an Array with the results

  • dojo.some

    Iterate over an array, escaping when the callback returns true for some logic check.

  • dojo.every

    Iterate over an array, escaping when the callback returns false for some logic check.

  • dojo.filter

    Iterate over an array, reducing the array based on the callback return.

  • dojo.indexOf

    Find the index of some element in an Array.

  • NodeList array methods

    • NodeList.indexOf, NodeList.lastIndexOf, NodeList.forEach, NodeList.every, NodeList.some, NodeList.concat, NodeList.map, NodeList.filter, NodeList.at

Language Utilities (dojo/_base/lang)

  • dojo.hitch

    Function that generates a wrapper function that ensures a function that will only ever execute in a defined scope.

  • dojo.partial

    Function that generates a wrapper function that ensures a function will only ever execute globally.

  • dojo.clone

    Clones objects (including DOM nodes) and all children.

  • dojo.delegate

    Returns a new object which “looks” to obj for properties which it does not have a value for.

  • dojo.isString

    Checks if the parameter is a String

  • dojo.isArray

    Checks if the parameter is an Array

  • dojo.isFunction

    Checks if the parameter is a Function

  • dojo.isObject

    Checks if the parameter is an Object

  • dojo.isArrayLike

    Checks if the parameter is like an Array

  • dojo.isAlien

    Checks if the parameter is a built-in function

  • dojo.trim

    Trim whitespace from a String

  • dojo.replace

    Simple templates with parameterized substitutions.

  • dojo.mixin

    Mixes one object into another. Can be used as a shallow copy

  • dojo.extend

  • dojo.getObject

    Get a property from a dot-separated string, such as “A.B.C”

  • dojo.setObject

    Set a property from a dot-separated string, such as “A.B.C”

  • dojo.exists

    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)

Kernel (dojo/_base/kernel)

from 1.7 + dojo/_base/kernel module collects following part of dojo APIs

Window (dojo/_base/window)

from 1.7 + dojo/_base/window module collects following part of dojo APIs

  • dojo.doc

    Alias for the current document.

  • dojo.body

    Return the body element of the document

  • dojo.setContext

    Changes the behavior of many core Dojo functions that deal with namespace and DOM lookup

  • dojo.withGlobal

    Call callback with globalObject as dojo.global and globalObject.document as dojo.doc

  • dojo.withDoc

    Call callback with documentObject as dojo.doc

Effects (dojo/_base/fx)

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:

NodeList (dojo/_base/NodeList)

  • NodeList.connect

    Connects events to every node in the list, like dojo.connect

  • NodeList.events

    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)

Ajax / XHR (dojo/_base/xhr)

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.

JSON Tools (dojo/_base/json)

  • dojo.fromJson

    Parses a JSON string to return a JavaScript object

  • dojo.toJson

    Returns a JSON serialization of an object

Objects / OO Tool (dojo/_base/declare)

Colors

  • dojo._base.Color

    Color object and utility functions to handle colors. Details on

  • dojo.colorFromArray

  • dojo.colorFromHex

  • dojo.colorFromString

  • dojo.colorFromRgb.

Miscellaneous Base

  • dojo.global

    Alias for the global scope

  • dojo.keys

    A collection of key constants.

  • dojo._Url

    dojo._Url is used to manage the url object.

  • dojo/_base/sniff

    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

  • dojo.byId

    Select a DOM node by ‘id’.

  • dojo.isDescendant

  • dojo.setSelectable

  • Manipulation (dojo/dom-construct)

    • dojo.toDom

      Instantiates an HTML fragment returning the corresponding DOM.

    • dojo.create

      Creates a dom node with optional values and placement

    • dojo.place

      Place DOM nodes relative to others

    • dojo.destroy

      Destroy a DOM element

    • dojo.empty

      Empty the contents of a DOM element

  • Attributes (dojo/dom-attr)

    • dojo.attr

      Modifying DOM node attributes

    • dojo.getAttr

      Gets an attribute on an HTML element.

    • dojo.setAttr

      Sets an attribute on an HTML element.

    • dojo.hasAttr

      Returns true if the requested attribute is specified on the given element, and false otherwise.

    • dojo.removeAttr

      Removes an attribute from an HTML element.

    • dojo.getNodeProp

      Returns an effective value of a property or an attribute.

  • Form (dojo/dom-form)

  • Styles (dojo/dom-style)

  • Class (dojo/dom-class)

    • dojo.hasClass

      Returns a boolean depending on whether or not a node has a passed class string.

    • dojo.addClass

      Adds a CSS class to a node.

    • dojo.removeClass

      Removes a class from a Node.

    • dojo.toggleClass

      Toggles a className (or now in 1.4 an array of classNames).

    • dojo.replaceClass

      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)

    • dojo.coords

      Getter for the coordinates (relative to parent and absolute) of a DOM node. Deprecated in Dojo 1.4.

    • dojo.position

      Getter for the border-box x/y coordinates and size of a DOM node.

    • dojo.marginBox

      Getter/setter for the margin-box of node

    • dojo.contentBox

      Getter/setter for the content-box of node

    • dojo.getMarginBox

      Get an object that encodes the width, height, left and top positions of the node’s margin box.

    • dojo.setMarginBox

      Sets the size of the node’s margin box and placement (left/top), irrespective of box model.

    • dojo.getContentBox

      Get an object that encodes the width, height, left and top positions of the node’s content box, irrespective of the current box model.

    • dojo.setContentSize

      Sets the size of the node’s contents, irrespective of margins, padding, or borders.

  • Property (dojo/dom-prop)

IO-Query (dojo/io-query)

  • dojo.objectToQuery

    Takes a name/value mapping object and returns a string representing a URL-encoded version of that object.

  • dojo.queryToObject

    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)

  • dojo/robot

    Users who use doh+dojo get the added convenience of dojo.mouseMoveAt instead of computing the absolute coordinates of their elements themselves

  • dojo/robotx

    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)

  • dojo.ready

    Call functions after the DOM has finished loading and widgets declared in markup have been instantiated

AJAX I/O transports (dojo/io/*)

AJAX RPC transports (dojo/rpc/*)

Query (dojo/query)

  • dojo.query

    The swiss army knife of DOM node manipulation in Dojo.

NodeList (dojo/NodeList-*)

Browser’s History (dojo/back & dojo/hash)

  • dojo.back (dojo/back)

    Browser history management resources (Back button functionality)

  • dojo.hash (dojo/hash)

    Normalized onhashchange module

Store (dojo/store)

Cache (dojo/cache)

  • dojo.cache

    1.4+ A mechanism to cache inline text.

Date (dojo/date)

DND (dojo/dnd)

Miscellaneous Core

  • dojo.AdapterRegistry

    A registry to make contextual calling/searching easier

  • dojo.behavior

    Utility for unobtrusive/progressive event binding, DOM traversal, and manipulation

  • dojo.Stateful

    Get and set named properties in conjunction with the ability to monitor these properties for changes

  • dojo.aspect

    Provides aspect oriented programming facilities to attach additional functionality to existing methods

  • dojo.cldr

    A Common Locale Data Repository (CLDR) implementation

  • dojo.colors

    CSS color manipulation functions

  • dojo.cookie

    Simple HTTP cookie manipulation

  • dojo.currency

    Localized formatting and parsing routines for currency data

  • dojo.DeferredList

    Event handling for a group of Deferred objects

  • dojo.fx

    Effects library on top of Base animations

  • dojo.gears

    Google Gears

  • dojo.html

    Inserting contents in HTML nodes

  • dojo.i18n

    Utility classes to enable loading of resources for internationalization

  • dojo.jaxer

  • dojo.number

    Localized formatting and parsing methods for number data

  • dojo.parser

    The Dom/Widget parsing package

  • dojo.regexp

    Regular expressions and Builder resources

  • dojo.string

    String utilities for Dojo

  • dojo.mouse

    Provides extension events for hovering and mouse button utility functions

  • dojo/on

    Provides normalized event listening and event dispatching functionality

  • dojo/touch

    Provides standardized touch events

  • dojo.require

    Loads a Dojo module, by name

See also

  • Dijit

    The widget system layered on top of Dojo

  • DojoX

    An area for development of extensions to the Dojo toolkit