Basic Framework of dojo Quick Start Guide

Source: Internet
Author: User
Tags dojo toolkit
First download the dojo Library: http://www.dojotoolkit.org/downloads

Put it for testing. I will decompress the file to the "JS/dojotoolkit" folder of the Web server. If you want to, you can fix the version number. The final directory structure should be like this:

It is important to clarify the path of the dojo. js file. As long as Dojo. js can be correctly loaded into the page, the package system automatically handles references and dependencies to related modules.

The dojo book provides a large number of guides and tutorials, and provides a more in-depth introduction to various methods for obtaining different dojo versions.

You can also introduce the script from the Google Public Library, as shown below: http://ajax.googleapis.com/ajax/libs/dojo/1.3.1/dojo/dojo.xd.js

Basic Framework

Below is a dojoProgramBasic Framework:

<! Doctype HTML public "-// W3C // dtd html 4.01 // en"
Http://www.w3.org/TR/html4/strict.dtd>
<HTML>
<Head>
<Title> dojo toolkit test page </title>

<! -- Load the basic dojo library -->
<SCRIPT type = "text/JavaScript" src = "JS/dojotoolkit/dojo. js"
Djconfig = "parseonload: True, isdebug: True">
</SCRIPT>

<SCRIPT type = "text/JavaScript">
/* Other script programs */
</SCRIPT>

<Style type = "text/CSS">
/* The style sheet is here */
</Style>

</Head>
<Body> <! -- Page content -->
<H1 id = "testheading"> basic dojo framework <Div id = "contentnode">
<P> some content </P>
</Div>
</Body>

</Html>

Configure the dojo startup parameters

You should configure parameters when loading dojo. The two most important parameters are parseonload and isdebug. The first parameter determines whether to parse the dojo component and built-in labels when loading the page. The second parameter enables or disables debugging information. There are two configuration methods:

The first method is configured in the <SCRIPT> label as follows:

<SCRIPT type = "text/JavaScript" src = "JS/dojotoolkit/dojo. js"
Djconfig = "parseonload: True, isdebug: True">
</SCRIPT>

The second method is to create a global variable djconfig before dojo. JS is loaded, as follows:

<SCRIPT type = "text/JavaScript">
VaR djconfig = {
Isdebug: True,
Parseonload: True
};
</SCRIPT>
<SCRIPT type = "text/JavaScript" src = "JS/dojotoolkit/dojo. js"> </SCRIPT>

The two methods have the same effect.

How to start?

Because browsers of different versions have different definitions for the "ready" Status of page loading, Dojo provides a dojo. addonload function. The program starts from this, as shown below:Code:

// A function
VaR init = function (){
Console. Log ("I run after the page is ready .");
};
// Run the above function after ready
Dojo. addonload (init );

// This is another form, using anonymous Functions
Dojo. addonload (function (){
Console. Log ("I also run, but second .");
});

Important: Do not use <body onload = "somefunc"> and window. onload = somefunc to start your function. Instead, use dojo. addonload (somefunc)

More

With the dojo. Require () function, package system automatically loads all the code you need. The following example loads a button and a titlepane, and the system will automatically find their code, as shown below:

Dojo. Require ("dijit. Form. Button ");
Dojo. Require ("dijit. titlepane ");
Dojo. addonload (function (){
Dojo. byid ("testheading"). innerhtml = "we're on our way! ";
Console. Log ("onLoad fires after require () is done ");
});

Each module has its own dojo. Require () parameters. You can find them from dijit API pages.

Continue

In the preceding dojo. byid () function, the element is selected by ID and the innerhtml value of the element is changed. We will understand the selector later.

Place the above Code in the "other script programs" position in the framework and run it. If you see: "We're on our way", congratulations!

If an error occurs, you can find the common error information from the FAQ.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.