• map
See also:
• Defining Modules
• The Dojo Loader
• sitepen: Dojo FAQ: How does passing a configuration object to require work? - 2014-01-22
• sitepen: Dojo FAQ: What is the map config option? - 2013-07-03
• sitepen: Dojo FAQ: What is the difference between a package, a path and an alias? - 2013-06-20
Event Handling
The web programming model of the world is that we set up an environment and then wait for
external events to occur to which we respond. Think of a web page that you may wish to work
with. You enter its URL and then it displays itself for you. Until you interact with it such as
moving the mouse or clicking on a button, the page is usually quite passive.
If we are writing our own widgets, if we add the "dojo/Evented" package into our inheritance
chain then a widget instance will have an "on()" method associated with it as well as the ability to
"emit()" events. In the declare() method of the widget, add "Evented" in the array of
inherited widgets where "Evented" is the alias for "dojo/Evented".
Within the dojo world, we set up our environment and then register the events such that, when they
occur, we will be notified.
• onBlur – Called when focus is removed from a widget.
• onChange – Called when the data associated with a widget has changed.
The "emit()" method has two parameters:
• The name of the event to emit.
• The object that is the payload of the event. This must be an object. A scalar will not work.
See also:
• Documentation – dojo/on – 1.9
• Documentation – dojo/Evented – 1.9
• Events with Dojo – 1.9
• sitepen - Dojo FAQ: What properties are available to me on the event object when using dojo/on? - 2013-04-26
REST/Ajax calls
Ajax calls are made with the standard XmlHttpRequest object from browsers. Abbreviating
this we get XHR. Since Ajax is a pattern of using REST, this story also applied to making REST
calls. Dojo provides a module called "dojo/request/xhr" which is commonly bound to the
variable "xhr".
When called, it returns a Dojo Deferred which is called back when the REST request completes.
The general format of using xhr is:
• xhr.get() - make an HTTP GET request
• xhr.put() - make an HTTP PUT request
Page 140
Comentários a estes Manuais