Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Scott on Oct 12, 2009 11:07
open dhtmlx forum
AttachEvent won't link to webpage

I'm using the following code to create a simple XML based site map; here is the code;

    <script>
            tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);            
            tree.setSkin('dhx_skyblue');
            tree.setImagePath("../Sitemap/common/images/");
            tree.enableDragAndDrop(0);
            tree.enableTreeLines(false);
            tree.setImageArrays("plus","","","","plus.gif");
            tree.setImageArrays("minus","","","","minus.gif");
            tree.setStdImages("book.gif","books_open.gif","books_close.gif");    
            tree.setXMLAutoLoading("../Sitemap/MenuTree.xml");
            tree.loadXML("../Sitemap/MenuTree.xml");
    </script>
    
    <script>//tree.attachEvent("onClick",function(id){document.location.href=tree.getUserData(id,"url");return true;});</script>

Here is a snippet of the XML. Only the first line is formatted as a link;

<?xml version='1.0' encoding='iso-8859-1'?>
<tree id="0">
<item text="RSOPS Website" id="root" open="1" call="1" select="1">
    <item text="Home" id="Homepage" ><userdata name="url">http://www.rsoperations.com/index.php</userdata></item>
    <item text="Projects" id="pr" open="1" >
        <item text="Florida" id="pr_1" />
        <item text="Philippines" id="pr_2" />
        <item text="South Seas" id="pr_3" />
    </item>

Here is a link to a live page;

http://www.rsoperations.com/SiteMap/SiteMapInclude.html

I have to comment out the attachEvent function or the tree will load and then immediately go to the "PAGE NOT FOUND MESSAGE" and you cannot see the source code.

Please Help!
Answer posted by Alex (support) on Oct 13, 2009 01:46

The select="1" and call="1" attributes mean that onClick event will be called for an item. In case of your xml, for "root" item:

<item text="RSOPS Website" id="root" open="1" call="1" select="1"> 

Userdata isn't defined for this node and tree.getUserData("root","url") returns undefined