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
|
This is as vanilla as it gets. We've put the Dojo script tag into the <head> — it could also have gone at the end of the <body> — with a src attribute indicating the URL where thedojo.js
file is located.
dojo.ready
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.
<script>
dojo.ready(
function
(){
"Dojo version "
+ dojo.version +
" is loaded"
);
});
>
>
>