[Solved] 'unique' data value (how to ?)
Hi,
I have this little problem which I can't seem to solve.
So I have an object with a 'X' data stored.
I want to store a copy of this data inside the same object.
- var object = $( '#mydiv' );
- object.data( 'X', 'something' );
- var copy = object.data('X');
- object.data( 'Y', copy);
The probleme is that X and Y seem to be linked, but I would like Y to remain the same regardless of what happens to X.
So I found this complicated way to force the creation of a new object (the variable 'X' is a table) :
- var copy = object.data('X');
- var newCopy = copy.join(',').split(',')
But surely, there must be a simpler way.
I've read the following technique in the forum, but I'm not too comfortable with it, as it creates a new Jquery object, while the original value is a simple array :
- var copy = $.extend({}, object.data( 'X' ));
Probably there's some fundamental concept I didn't get, well, I'm new to this !
Any help will be welcome.