Calendar does not currently have a destroy method. It should. I'll look at adding it for the 2.6.0 release.
Here's a quick example, if you want to try adding it to the current version of Calendar:
NOTE: I believe Custom Event listeners should be gc'able as soon as the last remaining reference you have to the Calendar object is gone, so there doesn't seem to be a need to unsubscribe these listeners - but I'll check on this. There may be if custom events or it's subscribers are referenced somewhere outside of the Calendar object.
] On Behalf Of Mark A. Ziesemer
Sent: Monday, May 19, 2008 1:16 PM
I've noticed that the Calendar component does not have a "destroy" or
seemingly equivalent method. The closest I've found is the "destroy"
method on the Calendar's "cfg" object, e.g. "calendar.cfg.destroy()".
Combined with removing the Calendar's generated DOM structure, is the
"cfg.destroy()" call necessary or sufficient to clean-up / garbage
Other widgets e.g. DataTable and the container components (Panel,
Dialog, etc.) expose a "destroy()" method, which not only clears the
generated DOM, but removes all registered event listeners, etc.
Please correct me if I'm wrong - but I don't see where Calendar is
doing any clean-up work, if it is at all. I haven't seen anything
mentioned in the documentation, examples, this forum, or bug reports
related to "Calendar".
This concern seems to be slightly mitigated when a created Calendar is
reused across multiple calls for the same use, or potentially better,
shared across calls for different uses.
While some of the examples take the "reuse approach", one particular
usage of concern is the "editDate" (or "date" shortcut) editor
function in DataTable. It appears that every time a date cell is
edited, the "editDate" function is called, which creates a new
Calendar, with no apparent effort to clean-up once the editor is
closed. This includes at least the one new listener subscribed to the
"selectEvent", not to mention the additional listeners that are
created and subscribed internally.
Any comments / thoughts / corrections would be appreciated. Thanks!