Bubbling Library > Examples

Dispatcher - How to avoid memory leaks

In this example, you can see how the first tab "Datatable Control" defines the rules to destroy the YUI Datatable before changing the content of the tab (which means that every time you click on the first tab, the dispatcher will destroy the DataTable control, releasing the memory and then will display the new content). Also, by default, the dispatcher will release all the listeners defined for a dynamic area before displaying the new content (YAHOO.util.Event.purgeElement).

// setting the destruction's rules
YAHOO.plugin.Dispatcher.destroyer.subscribe (function(el, config){
myDataTable.destroy ();
});