469,275 Members | 1,810 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Prototype: Ajax.Request

Airslash
221 100+
Hello,

currently I have 2 functions thatI'm trying to get to work together. Both functions make use of the Prototype library.

The first function moves a div container with ID _tooltip on the screen. This element is positioned absolute and uses the clonePosition to get the coords from its caller (_parent) and then adds an offset to prevent overlap.
This function works.
Expand|Select|Wrap|Line Numbers
  1. function relocateTooltip(_tooltip, _parent, _order) {
  2.     // OffSet variables
  3.     var left = _parent.getWidth();
  4.     var top = 0;
  5.  
  6.     // Check the top offset. reposition if we're the last element.
  7.     if( _order == true) {
  8.         top = $(_parent).getHeight() - _tooltip.getHeight();
  9.     } else {
  10.         top = $(_parent).getHeight();
  11.     }
  12.  
  13.     // position our tooltip witht the calculated values
  14.     _tooltip.clonePosition(_parent, {
  15.         'offsetLeft': left,
  16.         'offsetTop': top
  17.     });
  18. }
  19.  
Now I'm trying to use a second function to fetch data from another page using an AJAX call. The idea behind this is to have a tooltip with live data.
The problem however is that the onSuccess statement never gets called. and the relocation function doesnt work.
If I put everything seperatly then it works, but relocation functions lacks data then.
Expand|Select|Wrap|Line Numbers
  1. function loadContent(_tooltip, _url, _caller, _order) {
  2.     new Ajax.Request(_url, {
  3.         method: 'get',
  4.         onSuccess: function(transport) {
  5.             _tooltip.innerHTML = transport.responseText;
  6. // this part is not working for some reason.
  7.             relocateTooltip(tooltip, _caller, _order);
  8.         },
  9.         onCreate: function(transport) {
  10.             _tooltip.innerHTML = '<img src="/images/tooltip/load_bar.gif" alt="Loading..." />';
  11.             relocateTooltip(tooltip, _caller, _order);
  12.         }
  13.     });
  14. }
  15.  
What I want to know is, how I can make my relocateTooltip call get the parameters from the original function call.
Feb 2 '09 #1
3 1444
acoder
16,027 Expert Mod 8TB
Should it not be _tooltip in place of tooltip?
Feb 2 '09 #2
Airslash
221 100+
yeah it's a typo I discovered after posting :p

Also managed to solve the problem. Was collecting the height of the wrong node.Need to drop down 2 levels
Feb 2 '09 #3
acoder
16,027 Expert Mod 8TB
Well. that's good. Glad you got it sorted.
Feb 2 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Jean-Philippe Encausse | last post: by
45 posts views Thread by bigdadro | last post: by
31 posts views Thread by Tony | last post: by
5 posts views Thread by Gerry Vandermaesen | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.