Current attributes in models become previous attributes too early#373
Current attributes in models become previous attributes too early#373curvedmark wants to merge 13 commits intojashkenas:masterfrom
Conversation
|
I'm afraid that the current behavior is how things are supposed to work. Previous attributes are only available during the course of a "change" event. Without this, the entire notion of If you're looking for more robust undo-like functionality, I'd recommend keeping a true list of previous versions of the model. |
|
Thanks for the advice. But can you explain more on why |
|
+1 to this commit. It makes it easy to patch the Backbone.sync method for syncing only what has changed |
Firefox has a bug that auto-decodes the hash fragment (https://bugzilla.mozilla.org/show_bug.cgi?id=483304), which makes it impossible to have a hash like '#%23backbone.js'.
Collection.reset/add should invoke Model's parse function (with tests)
Fixes issue 498.
|
+1 to this commit |
|
@braddunbar, @tgriesser Any opinions on the semantics of this patch? |
|
Well, the patch is really out of date (0.5.3) so I'd be curious to see what something like this looks like in the current form of the library. I'm not certain but I believe this might actually be the behavior in the latest? #2159 |
|
Right, sorry. Wasn't thinking. |
|
I realized after I +1'd it that it was pretty old code base. I'd be interested in delving more into it and submitting a patch, so I'll do that with a fork and submit it with the newer code base. I tried to do this currently on the latest master branch and it still works the old way (previous gets overwritten by attributes during the end of set). |
|
The problem still persist if we have more than 1 model properties. Please see below example. Backbone version 1.1.2 |
The resetting of previous attributes seems to happen too early, i.e., as soon as all event listeners are called, current attributes become previous attributes, which really should happen the next time set() is called, otherwise the following code fails:
The output should be
val1and in backbone 0.3.3 it'sval2