Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{div:class=api-page}

h1. fluid.copy(tocopy)
{section}
{column:width=70%}
Performs a deep copy (clone) of the object passed in the argument.
{code:javascript|borderStyle=none|bgColor=white}
fluid.copy(tocopy);
{code}
*File name:* {{Fluid.js}}

h2. Parameters

{span:class=borderless-table}
|*{{tocopy}}*| (Object) The object to be copied |
{span}

h2. Return Value
{span:class=borderless-table}
|*Object*| The copied object |
{span}

{column}

{column:width=5%}
{column}

{column}
h3. See Also
{column}
{section}
----

h3. Notes

This function uses {{jQuery.extend()}} to recursively copycopies the contents of {{tocopy}} into a new object of the same type.

h3. Example
{code:javascript}
var oldModel = fluid.copy(that.model);
{code}
In this example, {{fluid.copy()}} is being used to preserve a copy of a model. This can be useful for scenarios where some kind of 'revert' or 'undo' might be desirable.
{div}