http://dojotoolkit.org/documentation/tutorials/1.6/hello_dojo/
Hello Dojo!
Welcome! In this tutorial,we'll start from the ground up,with a simple HTML page. By the end of this tutorial,we'll have loaded Dojo into the page,as well as put some of the core functions to work. We'll touch on Dojo's modular structure,and discuss how to load dependencies into the page to make a richer experience.
- Difficulty:Beginner
- Dojo Version:1.6
Getting Started
Our starting point is a simple HTML page. We want to load Dojo into the page and add some code to signal our success.
1
2
3
4
5
6
7
8
9
10
11
12
|
dojo.js
file is located.
For this tutorial we are going to load the Dojo Toolkit via the Google CDN. If you have downloaded a Dojo release,adjust the URL to point to the location of dojo.js on your own server. Assuming the URL is correct,Dojo is Now loaded quietly in the background. Next we need somewhere to put code that runs when Dojo is ready,so we can do something with it.
dojo.ready
@H_404_155@ Readiness,as it relates to an HTML page and the browser,can be a slippery moment to pin down. We need both the DOM to be ready for manipulation,and Dojo (and any indicated dependencies — more on that in a minute) to be loaded before any of our JavaScript code runs. Becausereadyhas different meanings in different browsers,Dojo provides a reliable,cross-browser function for the purpose:dojo.ready
. We pass it a function,and that function gets executed at thereadymoment.
6
7
12
13
14
15
16
17
<script>
dojo.ready(
function
(){
alert(
"Dojo version "
+ dojo.version +
" is loaded"
);
});
</script>
>
>
>
>
>