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
- function relocateTooltip(_tooltip, _parent, _order) {
- // OffSet variables
- var left = _parent.getWidth();
- var top = 0;
- // Check the top offset. reposition if we're the last element.
- if( _order == true) {
- top = $(_parent).getHeight() - _tooltip.getHeight();
- } else {
- top = $(_parent).getHeight();
- }
- // position our tooltip witht the calculated values
- _tooltip.clonePosition(_parent, {
- 'offsetLeft': left,
- 'offsetTop': top
- });
- }
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
- function loadContent(_tooltip, _url, _caller, _order) {
- new Ajax.Request(_url, {
- method: 'get',
- onSuccess: function(transport) {
- _tooltip.innerHTML = transport.responseText;
- // this part is not working for some reason.
- relocateTooltip(tooltip, _caller, _order);
- },
- onCreate: function(transport) {
- _tooltip.innerHTML = '<img src="/images/tooltip/load_bar.gif" alt="Loading..." />';
- relocateTooltip(tooltip, _caller, _order);
- }
- });
- }