I have been using an ajax tooltip, which has been working fine until I started using struts tiles.
In my mainLayout.jsp (Defines layout for all tiled pages)I also have a scrollable pane (scrollabletable.js).
The problem is that when the page loads the first 2 tooltips show fine until I scroll down then I cant see the other tooltips because its like the page has not refreshed the position of the tooltips to match the scrolling.
Can anyone help me out with this?
Thanks
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
0
Sounds like your code does not account for scrollTop and scrollLeft.
Eric
Danny Carson
Greenhorn
Joined: Aug 05, 2008
Posts: 18
posted
0
could you elaborate some more on that?
thanks for the reply
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
0
Without seeing the tooltip code. No...
Eric
Danny Carson
Greenhorn
Joined: Aug 05, 2008
Posts: 18
posted
0
think this is main part of interest.
Danny Carson
Greenhorn
Joined: Aug 05, 2008
Posts: 18
posted
0
can anyone offer any suggestions?
Jason Edgewalker
Greenhorn
Joined: Aug 12, 2008
Posts: 1
posted
0
Despite the fact that, on the face of it, this shouldn't be a big deal, the problem of calculating offset can be messy. Not surprisingly, the solution varies between browsers.
There's a great section in one of O'Reilly's DHTML books that talks about this. Here's a snippet that might be helpful, because it deals with scroll offset, which has to be taken into account for IE.
Hopefully it's helpful.
function getPageEventCoords(evt) { var coords = {left:0, top:0}; if (evt.pageX) { coords.left = evt.pageX; coords.top = evt.pageY; } else if (evt.clientX) { coords.left = evt.clientX + document.body.scrollLeft - document.body.clientLeft; coords.top = evt.clientY + document.body.scrollTop - document.body.clientTop; // include html element space, if applicable if (document.body.parentElement && document.body.parentElement.clientLeft) { var bodParent = document.body.parentElement; coords.left += bodParent.scrollLeft - bodParent.clientLeft; coords.top += bodParent.scrollTop - bodParent.clientTop; } } return coords; }
Danny Carson
Greenhorn
Joined: Aug 05, 2008
Posts: 18
posted
0
Hey
Thanks for the reply. I ended up scrapping the scroll table in the end. But I will keep the book in mind for the future.