Wednesday 27 January 2016

Loading Dojo Example

Dojo is one of the fast growing Javascript technology,it is very easy to use and provides a feel for a programmer as we working with an object oriented programming.

In this tutorial we walk through how to load basic dojo script into your file(HTML).
Before we start programming with DOJO we need to get latest dojo modules ,you can get those modules form dojo official website or click here..

here is the HTML code :

<html>
<head>
<!--Load Dojo Configuration here-->
<script>
//before loading main module try to load initial configurations
var djConfig={
isDebug:true,
parseOnLoad:true
};
</script>

<!--Load main dojo script Assuming it has relative path to the main project-->

<script
type="text/javascript"
src="./dojo/dojo.js"

></script>

</head>

<body>

<span>Dojo Load Testing</span>
<!--Load scrpit-->
<script>

dojo.addOnLoad(function(){//calling script immediately once page is loaded takes an anonymous function.
alert("Hey,It's Me DOJO Loaded For You..");
});

</script>
</body>

</html>


Explanation:

First and foremost thing is we need to load dojo configurations that can be loaded by using djConfig.
djConfig is an object that have initial loader configuration parameters to be set.in our code we specified two configuration parameters 1.isDebug 2.parseOnLoad
isDebug parameter tells the browser we are going to debug the code while running it through firebug(firebug is a standard tool referred by DOJO)
parseOnLoad parameter tells the page will parse automatically for checking any widgets that are needed to instantiate.
once page is loaded i am calling method addOnLoad() that do all work for us.




OutPut:


No comments:

Post a Comment