The recent up tick in forum activity is indeed pleasing to note!
I wish to offer some words of
caution
regarding the increased appearance of code containing event listeners and to a lesser extent observers.When you employ these quite useful techniques you must also provide an explicit means to remove them.
- Each time a button with a listener/observer is initialized a new (listener/observer) instance is created and the old instance is abandoned/orphaned.
- Abandoned/orphaned as this instance may be, it still exists in memory.
- Thus creating a memory leak.
So! - You must provide for detecting the presence of the listener and remove it if found.
- Then create the new instance within the initialization code on button initialization.
- You must also provide for its removal for window close.
- Because each instance of FF initializes a completely new set of Custom Buttons² buttons.
- The code block below documents a provision within Custom Buttons² for setting up to handle the window close event or you can create your own if so inclined.
- Edited by SCClockDr @ Sat Mar 22 2008 8:53:39 AM GMT-0400 (Eastern Daylight Time)
- A correction! Window close functionality not implemented as yet. But please do implement the code illustrated below because I intend to base the implementation on this structure.
- Edited by SCClockDr @ Sat Mar 22 2008 8:53:39 AM GMT-0400 (Eastern Daylight Time)
- Code: Select all
//To initiate
custombuttons.listeners.yourUniqueName = document.getElementById(IDoftheObjectYouareGoingtoListento);
custombuttons.listeners.yourUniqueName.addEventListener("popupshowing", ListenerFunctionDefinition, false);
// These will be closed out by Custom Buttons² automatically on window close.


your code?
