PDA

View Full Version : onclick firing when page loads for tree with menu



nilacqua
29 Jan 2010, 10:26 AM
I'm creating a page tree using dhtmlx pro tree. The page tree has a right click menu, but what I'm concerned with now is trying to have a left click cause an edit page to open. What I've found is that when the tree loads, the last node to load has the onclick function occur for it. In the below example, when the page tree is loaded, an alert occurs with the final pageId. I'm not sure if this is a bug or if there is something I'm missing but the code below feels very straightforward.

menu=new dhtmlXMenuObject(null, "dhx_black");
menu.renderAsContextMenu();
menu.setIconsPath("/images/");
menu.setOpenMode("web");
menu.attachEvent("onClick",onMenuSelection);
menu.loadXML("/Tree/contextmenu");

tree=new dhtmlXTreeObject('treeBox',"100%","100%",0);
tree.setImagePath("/js/dhtmlxTree_v25_pro/dhtmlxTree/codebase/imgs/");
tree.enableDragAndDrop(true, true);
tree.setDragBehavior("complex");
tree.enableContextMenu(menu);
tree.enableHighlighting(true);
tree.enableTreeLines(false);
tree.loadXML("/Tree/getCustomerPageTree");

tree.attachEvent("onClick", function(id){alert(id); return true;});
tree.attachEvent("onSelect", setId);
tree.attachEvent("onBeforeContextMenu", showDelete);
tree.attachEvent("onDrag", movePage);

30 Jan 2010, 1:51 PM
I'm confused! are you using ExtJS or Gxt or something completely foreign? What is DHTMLX tree? Are you sure you're posting on the right site?