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:



    

    





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

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;


});


This is how I’m initing the tree:




    
    




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?

Robert


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.

html is tough !

the code looks okay though …