Guys & Gals,
I'm trying to create a generic div that refreshes itself, and when you click a link from inside it, it submits to the div rather than reload the page. The div pretty much behaves like an iframe.
The idea is to use the updateManager's on "load" event to attach onclick events to the links inside the loaded div.
So far so good. With Jack's top notch doco, I'd managed to get stuff up and running. Everything seems to work. (see code at bottom)
However, despite taking some advice from http://jibbering.com/faq/faq_notes/closures.html, the code below still leaks memory.
The question is, has anyone tried anything similar? Any thoughts on what could be wrong? Is there any newbie thing I've completely missed out on?
Does 'startAutoRefresh' have some sort of memory footprint?
Does attaching events through addManagedListener cause memory to be leaked?
Any hints on how I'd be able to debug what's in memory?
FYI, by leaking I mean that the memory footprint just keeps on growing (~1.5GB overnight). In an hour, FireFox went from 45MB -> 170MB and IE went from 38MB -> 420MB in half an hour.
Thanks,
Mark C
PS I'm using 0.33 RC3
Code:
<div id="latestChanges">
</div>
<script type="text/javascript">
function initPortletlatestChanges()
{
var portlet = getEl('latestChanges');
var updateManager = portlet.getUpdateManager();
updateManager.showLoadIndicator = false;
updateManager.on('update', rewriteFormAndLinks);
portlet.load('/ajax/myChanges.action');
updateManager.startAutoRefresh(10);
}
YAHOO.util.Event.onAvailable('latestChanges', initPortletlatestChanges);
</script>
and the 'rewriteFormAndLinks' looks a bit like:
Code:
function ajaxClickHandler(e, updateDivId)
{
e.preventDefault();
var updater = getEl(updateDivId).getUpdateManager();
var link = e.findTarget('internalLink', 'a');
updater.update(link.href);
}
function rewriteFormAndLinks(el, oResponseObject)
{
var updater = el.getUpdateManager();
var links = el.getChildrenByClassName('internalLink', 'a');
for (var i = 0; i < links.length; i++)
{
links[i].addManagedListener('click', ajaxClickHandler, el.id);
}
}