Attaching a popup to a tree node

I tried the code posted here viewtopic.php?f=3&t=29946&start=0 for getting a popup to appear when a tree node is clicked. But it doesn’t take into account expanded parent nodes. If a parent node is expanded and you click on the parent node the popup will not appear (point) to it because of the height issue. Example…


So I adjusted your code slightly and I have it working nicely now, see below. But I’m wondering if it’s possible to accomplish this using only DHTMLX and not jQuery?

[code]getPopUpOpenCoords = function(inp) {
this.x = window.dhx4.absLeft(inp);
this.y = window.dhx4.absTop(inp);
this.w = inp.offsetWidth;
this.h = inp.offsetHeight;
};

tree.attachEvent(“onClick”, function(id) {
myPop = new dhtmlXPopup({mode: “right”});
var node = tree._globalIdStorageFind(id).htmlNode;
var theCorrectSpan = $(node).find(‘span:first’); //I would like to NOT use jQuery if possible
var coords = new getPopUpOpenCoords(theCorrectSpan[0]);
myPop.show(coords.x, coords.y, coords.w, coords.h);
myPop.attachHTML(“blah
blah
blah”);
});[/code]


Try to use instead .htmlNode propersty the next approach:

var node = tree._globalIdStorageFind(id).span;

You will not need jQuery to get the rest data :slight_smile:

tree.attachEvent("onClick",function(id){ var node = tree._globalIdStorageFind(id).span; var x = getOffset(node).left; var y = getOffset(node).top; var w = node.offsetWidth; var h = node.offsetHeight; myPop.show(x,y,w,h); myPop.attachHTML(id); });

Thanks Darya, works great!

You are welcome! :slight_smile: