Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Mustache live binding issue no2 (of 2)

$
0
0
The reason you see the changes reflected in the new Object is because you didn't create a new Object. Let me explain...

The parameters you passed to _.extend are backwards. The first parameter is the destination and the others are the sources. So what you did was extend each Observe's _data property with on empty object and return the result which is just the _data property. Everything in JavaScript is a pointer, so what you have pushed onto your Array is just a pointer to the Observe's _data so your list is always up to date with the Observe.

That said, there is a much easier way to support undo. can.Observe has a backup plugin that allows you to backup, change and then restore an Observe.

Viewing all articles
Browse latest Browse all 3491

Trending Articles