This project is archived and is in readonly mode.

#722 ✓invalid
jaywang

how to clone the element's store data?

Reported by jaywang | August 4th, 2009 @ 09:19 AM | in 2.0 (closed)

when I use the function [store] to store some data,I want to clone the node. cloneEvents can help us to clone the node's events.which function can help us to clone the node's store data?

Comments and changes to this ticket

  • Scott Kyle

    Scott Kyle August 4th, 2009 @ 05:26 PM

    There currently is no way to clone stored data because that is all stored privately and therefore you can't write a new Element method to have access to storage. You'll need to know which pieces of data you want to clone, and loop through those. This is much better practice anyway, because many values in storage should not be cloned, such as stored Fx objects that are automatically created when you call the tween, morph, fade, or highlight methods.

    I hope that helps. Please close as invalid.

  • Sebastian Markbåge

    Sebastian Markbåge August 4th, 2009 @ 10:57 PM

    • State changed from “new” to “invalid”

    Yes, what Scott said. Objects in store can be instance specific and could even have infinitely recursive references.

    But if you do have some data stored on a known node and you know that it doesn't contain such references. Then you can clone that property using $merge - which will do a recursive clone:

    var clonedData = $merge(element.retrieve('myData'));

    Please try the user group for more questions: http://groups.google.com/group/mootools-users

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Tags

Pages