Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ajax tooltip position problem

 
Danny Carson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like your code does not account for scrollTop and scrollLeft.

Eric
 
Danny Carson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you elaborate some more on that?

thanks for the reply
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing the tooltip code. No...

Eric
 
Danny Carson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
think this is main part of interest.

 
Danny Carson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone offer any suggestions?
 
Jason Edgewalker
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic