Rich Internet Applications with Dojo Toolkit 101 - Adding an event and styling
(Page 3 of 5 )
It is easy to add further functionality for both formatting and user interaction as shown in the following code. While the statement dojo.require("dojo.widget.Button") just provides reference to the Button object, the dojo.widget.* with the wild card provides reference to a wide set of widgets, but not all widgets.
<HTML>
<HEAD>
<TITLE> </TITLE>
<script type="text/javascript">
var djConfig = {isDebug: true};
</script>
<SCRIPT type="text/javascript" src="http://images.devshed.com/da/stories/
http://localhost/DoAjax/dojo.js"> </script>
<script type="text/javascript">
dojo.require("dojo.widget.Button");
</script>
<script type="text/javascript">
function test(){
alert ("Hello, Welcome to Dojo");
}
</script>
</HEAD>
<body> <h2>Test</h2>
<button dojoType="button" onClick="test"><span
style="color: green; font-weight:bold">Hi Dojo!</span></button>
</body>
</HTML>
The click event runs the function test() which brings up the alert box with the welcome message. Notice the formatting of the text inside the button by the style applied to the <span/> tag. Also notice the differences between the dojo syntax and the regular JavaScript syntax.
Next: The DatePicker and Accordion widgets >>
More JavaScript Articles
More By Jayaram Krishnaswamy