Not sure if this is possible in Dojo or JS for a function to return a object with two properties of vars? My codes do not work but just as my requirement:
function getObj()
{
var var1 = 123; // 123 as simple case, but it could be a DOM node
var var2 = 345; // another DOM node
return {v1: var1, v2: var2}; // any way to get two values back?
}
....
var obj = getObj();
console.log("obj.v1: " + obj.v1 + "; obj.v2: " + obj.v2); // not working but possible?
OK, here is my real function:
dojo.requre("dojo.html");
....
function getNodes()
{
var node = dojo.byId("div1"); // static <div> in html
var childen = "<div id='chart' style='width: 10px; height: 10px'></div><div id='legend'></div>";
dojo.html.set(node, children); // add two divs as children
var nodeChart = dojo.byId("chart");
var nodeLegent = dojo.byId("legend");
return {chart: nodeChart, legend: nodeLegend};
}
...
var nodes = getNodes();
var nodeChart = nodes.chart; // OK div#chart
var nodeLegend = nodes.legend; // nodes.legend is div#legend, but nodeLegend is undefined!