Categories | Question details Back To List | ||
tree menu - attachEvent problem Hi, I'm trying to use the following, but get a javascript error: tree.attachEvent("onClick",function(id){ document.location.href=tree.getUserData(id,"url"); return true; }); The error is because "tree" isn't defined. I'm not initing it in html, I'm using the following includes: <link href="../../css/dhtmlxtree.css" rel="stylesheet" type="text/css" /> <script src="../../js/dhtmlxcommon.js"></script> <script src="../../js/dhtmlxtree.js"></script> <script src="../../js/dhtmlxtree_start.js"></script> so I searched these for tree = new dhtmlXTreeObject and found this line : var t=new dhtmlXTreeObject(obj,"100%","100%",0); so I assume I would just substitute "t" for "tree", right? As in : var t=new dhtmlXTreeObject(obj,"100%","100%",0); t.attachEvent("onClick",function(id){ document.location.href=t.getUserData(id,"url"); return true; }); But this doesn't work... Any ideas? Robert Lewis Answer posted by Support on Oct 23, 2008 01:24 >> I'm not initing it in htm How do you initialize tree ? The following approach in absolutely correct, if you don't initialize tree from html var t=new dhtmlXTreeObject(obj,"100%","100%",0); t.attachEvent("onClick",function(id){ document.location.href=t.getUserData(id,"url"); return true; }); Answer posted on Oct 23, 2008 05:11 This is how I'm initing the tree: <link href="../../css/dhtmlxtree.css" rel="stylesheet" type="text/css" /> I guess my question is, if I init the tree with dhtmlxtree_start.js, what is the name of my tree so that I can access it through javascript? Answer posted by Support on Oct 23, 2008 06:41 it equal to value of ID attribute of HTML container <div id="mytree" setImagePath="../../codebase/imgs/csh_bluebooks/" class="dhtmlxTree" .... mytree.attachEvent( Please beware that object will be available only after document loading. You may try to use dhtmlXTreeFromHTML instead of init by class, such method will return object of tree initialized from HTML. |