Hi, 

I'm having an issue with Drag and Drop memory / cpu consumption which may be
a result of the way I refresh my DOM elements.  Hopefully someone has done
the following before and knows where I'm going wrong.  What I do is send my
javascript a set of html to inject (from my servlet), which includes divs of
a class that I turn into Draggables (and droppables) after injecting.  I
don't explicitly destroy the old draggables, and I think that when I
overwrite the DOM elements through this injection, they are somehow kept
around by mochikit.  Perhaps what I should do is find these old draggables
before injecting, delete them, then do as I do?  Here is some code to
illustrate :

retrievePresentation: function(result) 
{
    //load the elements from the server to the html                     
    var response = result.responseXML.documentElement;
    var content="";
    for( var i=0;
i<response.getElementsByTagName("contents")[0].childNodes.length; i++ ) {
        content +=
response.getElementsByTagName("contents")[0].childNodes[i].data;
    }
    var destination =
response.getElementsByTagName("destination")[0].firstChild.data;
    var drag_class  =
response.getElementsByTagName("draggable_class")[0].firstChild.data;
    var drop_class  =
response.getElementsByTagName("droppable_class")[0].firstChild.data;
    var presentationArea = document.getElementById(destination);
    presentationArea.innerHTML=content;
    //set up draggability if applicable
    if( drag_class != "none" ) {
                
        var allDraggablesArray =
MochiKit.DOM.getElementsByTagAndClassName('*', drag_class);
        for(var aDraggable in allDraggablesArray) { 
                                
            var widId = allDraggablesArray[aDraggable].id;
            new MochiKit.DragAndDrop.Draggable(widId);
        }
        if( drop_class != "none" ) {
                        
            var allDroppablesArray =
MochiKit.DOM.getElementsByTagAndClassName('*', drop_class);
            for(var aDroppable in allDroppablesArray) { 
                                        
                var widId = allDroppablesArray[aDroppable].id;
                new MochiKit.DragAndDrop.Droppable(widId, { ondrop:
MochiKit.Base.bind(this.onDrop, this)});
            }
        }
    }
}

Thanks for reading!
-- 
View this message in context: 
http://www.nabble.com/Drag-and-Drop-Memory-Issue-tp22548385p22548385.html
Sent from the MochiKit mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to 
mochikit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to