Hi there,

I've tried googling around for an answer to this, but either I'm using
the wrong keywords, or I'm just not getting the answer I'm looking
for..  Anyway, I'll give it a shot here.

I'm using Ajax.Updater to update a div with dynamic content.  Pretty
cut and dry and this works fine, no problem.  Once the content has
been updated, I want to place it on the screen based on the new
dimensions of the div.  In short, I'm looking to center the div in a
specific area of the screen.

The problem I seem to be running into, however, is that the first time
this occurs on page load, the width and height of the div return
zero.  This is after Ajax.Updater has been called.  I'm a bit confused
as to why, though, and I can't seem to find a workaround.

The code I'm using is as follows :

function showPopup(myItem, passid) {
   myDiv = $('hoverdiv');
   myItem = $(myItem);

   new Ajax.Updater('hoverdiv', 'getinfo.php?pass_id=' + passid,
{ method: 'get' });

   var myOff = myItem.cumulativeOffset();

   var newX = myOff[0] + (myItem.getWidth() - myDiv.getWidth()) / 2;
   var newY = myOff[1] + (myItem.getHeight() - myDiv.getHeight()) / 2;

   myDiv.style.top = newY + 'px';
   myDiv.style.left = newX + 'px';


This is called via an onclick event in a table.  myItem is the tr
element that was clicked and passid is an integer.

Can anyone point me in the right direction to resolve this?


You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to