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.
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.
What I want to know is, how I can make my relocateTooltip call get the parameters from the original function call.
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.
Code:
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.
Code:
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);
}
});
}
Comment