On 2/23/06, Ryan Gahl <[EMAIL PROTECTED]> wrote:
Todd is exactly right. What's also important to realize about this, is that when your DOM elements are destroyed by the update to innerHTML, any event handlers that were tied to them (onclick, etc..), are in danger of staying around in memory (especially if the handlers are closures which hold references to the DOM elements, called a circular reference). These memory leaks can be very detrimental to your application if they go unchecked.

Think of the control you're updating (the treeview) as a miniature page. Every time it's refreshed (via innerHTML), you need to re-setup all of it's client behaviors (which is what you're seeing now). But you also should take care to clean up all of it's resources before each update. You can do this by adding a dispose() method on your objects that detaches DOM event handlers, unregisters draggables and droppable... etc (basically any memory that the DOM elements which will be refreshed have a hold of needs to be released), and making sure dispose() gets called before the refresh happens.

yes, i had this problem earlier; i have set a hookEvents/unHookEvents that is is charge  of cleaning up things
when the fragment is reloaded, but the dispose() thing is better thx, i'll do that

Tarek


_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to