I have two seemingly related issues related to the javascript function defined in different places. The first problem I ran into was calling a function that I defined from firgbug or safari console. I defined a function called getRed that looks like this:
function getRed(row, col) {
I would like to be able to test this function from the console, but every time I try to call getRed (1,1); for example, I get this error: ReferenceError: getRed not defined
Do I need to make a special call to determine the namespace? I define this function in a javascript file called drawing.js, which is defined very early on my html page.
Another problem I ran into was calling the function defined in the same drawing.js file from the onChange method: of my dojo color palette. Here is the code for the color palette:
<script type="text/javascript" src="drawing.js"></script> //the method colorChange is inside drawing.js which is defined before the dojo //color palette <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js" djConfig="parseOnLoad: true"> </script> <script type="text/javascript"> dojo.require("dojox.widget.ColorPicker"); dojo.addOnLoad(function() { var c = new dojox.widget.ColorPicker({ onChange: function(val) { console.log("BEFORE"); colorChange(val); console.log("AFTER"); } }, "picker1"); }); </script>
Here is the definition of changeColor inside the drawing.js file:
function colorChange(val) { console("colorChange!"); }
Each time I click on the color picker, I get the following error: ReferenceError: colorChange is not defined.
I am very new to javascript, and I am sure that these two problems have very similar and simple solutions, but I could not find the answer on the Internet. Can someone help me?
I am sure the script is loading, as this screenshot shows: 
source share