Dojo's basic article _dojo

Source: Internet
Author: User
Suppose our engineering catalogue is as follows:

   --helloworld.html

|--js/

--dojo// * Here is the file below the Dojo package, listed below
       		 --Build.txt
--Changelog
--Demos

-- ..
--Dojo.js
--Dojo.js.uncompressed.js
--iframe_history.html
--LICENSE
--README
--src/

Now we create the helloworld.html file with the following code:
  <title>dojo:hello world!</title>

<!--section 1-->
<script type= "Text/javascript" src= "Js/dojo/dojo.js" ></script>



<body>
</body>
Add a widget button to the body
<button dojotype= "button" widgetid= "Hellobutton" >hello world!</button>

The above does not necessarily use Widgetid, with the usual ID on the line, the widget will itself into the Widgetid.
The following starts with section 2 code.
  <!--section 2-->
<script type= "Text/javascript" >

Introducing Libraries
Event.* is the handling of events, such as: Click on all the packages.
Dojo.require ("dojo.event.*");
Dojo.require ("dojo.widget.*");
Dojo.require ("Dojo.widget.Button");

function called after clicking the button
function hellopressed ()
{
Alert (' You pressed the button ');
}

Bind the Hellobutton Click event to the hellopressed () function
function init ()
{
var Hellobutton = dojo.widget.byId (' Hellobutton ');//Get Button Object
Dojo.event.connect (Hellobutton, ' OnClick ', ' hellopressed ')/bound, which is just one of the binding methods
}

Dojo.addonload (init); or, of course, the INIT function can be named another name
</script>
 
 This completes the helloworld.html code. Try it. 

Also, note that
if the init function is already running, it is useless to use document.getElementById again. Because Dom
has been changed by widgets. You can only use Dojo.widget.byId.

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.