Good luck with this, let us know if it works out. Quick glance at your code I can see an obvious error...
> var newElement = element.clone(true); //clone the node Element doesn't have a clone method. The native DOM element does have a cloneNode method though. -- http://positionabsolute.net On Aug 25, 2:15 pm, watermark86 <[email protected]> wrote: > I'm using 1.6.1rc3 to have access to Element.storage. I need to write > a function that deep clones an element and copies the Element.observe > events as well as the Element.Storage items with it. I've managed to > write the code that can copy one or the other. > > The problem comes in when I try to do both (copy the storage items and > the events.) I suppose due to Event.observe using the Element.storage > item, I can't seem to have the items that I've stored with > Element.store to copy while maintaining the Event.observe events that > I've copied. > > I can copy the observe events or the element.store events, but not > both. Below is some terrible code for review. Thanks for any help or > insults. > > deepClone: function(element) { > //deep clone node > var newElement = element.clone(true); //clone the node > > //stop observing because of IE BS > newElement.stopObserving(); > > //copy the item > var registry = Element.retrieve(element, > 'prototype_event_registry'); > if (!Object.isUndefined(registry)) { > registry.each( function(pair) { > var eventName = pair.key, responders = pair.value; > responders.each( function(r) { > Element.observe(newElement, eventName, > r.handler); > }); > }); > } > > //for all of the descendants, copy the event handlers > var srcdecend = element.descendants(); > var dstdecend = newElement.descendants(); > var numdecend = srcdecend.length; > > for(var i = 0; i < numdecend; ++i) { > //stop observing because of IE BS > dstdecend[i].stopObserving(); > //copy the registry > var registry = Element.retrieve(srcdecend[i], > 'prototype_event_registry'); > if (!Object.isUndefined(registry)) { > registry.each( function(pair) { > var eventName = pair.key, responders = > pair.value; > responders.each( function(r) { > Element.observe(dstdecend[i], > eventName, r.handler); > }); > }); > } > } > > return newElement; > } --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
