I work with Dojo and use the "Module Template" as described in Mastering Dojo . As far as I can see, this template is a common and widely used JavaScript template. My question is: how do we debug our modules?
So far, I have not been able to convince Firebug to show me the source of my module. Firebug seems to show only the Dojo eval statement used to execute the factory method. Therefore, I cannot go through my module. I tried putting the "debugger" instructions in the module code, and Firebug seems to stop correctly, but does not show the source.
Thoughtful sample code below. This is just an example of enough complexity to make the need for debugging believable; it is not intended for useful code.
Page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>console me</title>
<style type="text/css">
@import "../dojoroot/dojo/resources/dojo.css";
@import "../dojoroot/dijit/themes/tundra/tundra.css";
@import "edf.css";
</style>
<script type="text/javascript" src="../dojoroot/dojo/dojo.js">
</script>
<script type="text/javascript" >
dojo.registerModulePath("mytest", "../../mytest");
dojo.require("mytest.example");
dojo.addOnLoad(function(){
mytest.example.greet();
});
</script>
</head>
<body class="tundra">
<div id="bulletin">
<p>Just Testing</p>
</div>
</body>
</html>
java script I would like to debug
dojo.provide("mytest.example");
dojo.require("dijit.layout.ContentPane");
(function(){
var example= mytest.example;
example.greet= function(args) {
var bulletin = dojo.byId("bulletin");
console.log("bulletin:" + bulletin);
if ( bulletin) {
var content = new dijit.layout.ContentPane({
id: "dummy",
region: "center"
});
content.setContent('Greetings!');
dojo._destroyElement(bulletin);
dojo.place(content.domNode, dojo.body(), "first");
console.log("greeting done");
} else {
console.error("no bulletin board");
}
}
})();
source
share