Home Tutorialhelp Comment DOJO init()

 
 

Comment

Manish Purohit
DOJO init(),
July 9, 2008 at 2:31 PM

what for is the function init(){} is used in code


<html>

<head>
<title>button</title>
<script type="text/javascript">
dojo.require("dojo.event.*");
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.Button");

function helloPressed()
{
alert('Click on the Hello World Button');
}

function init()
{
var helloButton = dojo.widget.byId('helloButton');
dojo.event.connect(helloButton, 'onClick', 'helloPressed')
}

dojo.addOnLoad(init);
</script>


</head>

<body bgcolor="#FFFFCC">

<p align="center"><font size="6" color="#800000">Welcome to Roseindia Dojo Project</font></p>

<button dojoType="Button" widgetId="helloButton" onClick="helloPressed();">Hello World!</button>
<br>

</body>

</html>





why we have to

var helloButton = dojo.widget.byId('helloButton');
dojo.event.connect(helloButton, 'onClick', 'helloPressed')

why even after specifying onClick we again give this code and do we need to create var for all the element in the code

View All Comments | View Tutorial
Related Tutorial and Articles

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.