Wouldn't that method of referencing the drag handle create an unwanted
closure? As I've come to understand, javascript garbage collection
gets confused when a javascript object references a DOM element while
the DOM element references the same javascript object. This would be
counter-productive to the author's concerns about cleaning up a
draggable.  The draggable could be destroyed, the element could be
destroyed, but the memory used to reference the draggable and the
element would not be freed.

Or I could be wrong... Modern browsers seem to be coming to terms with
the memory leaks that are easily introduced with DOM.

Also with my own experiences with trying to write efficient code with
Prototype and Scriptaculous, I've found it is much more important to
destroy a Droppable since every Droppable is searched every time the
mouse moves while dragging a Draggable. If a Droppable is not cleaned
after use, any dragging can quickly come to a crawl.

On Sep 22, 12:07 pm, Matt Foster <[EMAIL PROTECTED]> wrote:
> element.dragHandle = new Draggable(element, { //bla });
> When the element comes into your method, just reference the dragHandle
> property.
> On Sep 22, 9:45 am, Grego <[EMAIL PROTECTED]> wrote:
> > I see you are talking about the onDrop callback of Droppables, which
> > is documented athttp://github.com/madrobby/scriptaculous/wikis/droppables
> > I was reacting to the documentation 
> > athttp://github.com/madrobby/scriptaculous/wikis/draggable
> > in which the example shows a new draggable being created followed by
> > the following lines...
> > // then destroy it when you don't need it anymore
> > mydrag.destroy();
> > ... which caused me to think that - oh new draggables should be
> > cleaned up when we are done with them. Now, for me, if I create an
> > object through an API, and cleanup is expected, then I expect the API
> > to provide a cleanup method. This way I know internal structures
> > within the API are properly updated. If I remove the draggable
> > directly from the dom then internal Draggables structures will
> > reference an element that no longer exists.
> > To me, it looks like the method provided by the API, 'destroy',
> > requires information (the draggable handle) which is not conveniently
> > available - hence my suggestion for an API cleanup method that can
> > work with information that is conveniently available at drop time -
> > namely the element.

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to