Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update previous attributes even in silent mode #850

Closed
wants to merge 1 commit into from

Conversation

fernandogmar
Copy link

It should be great to keep previous attributes updated even when set an attribute in silent mode

@jashkenas
Copy link
Owner

Nope -- the point of a "silent" change is that it isn't considered a change from the models point of view. Later, when the change actually occurs, you get the full difference all at once.

@jashkenas jashkenas closed this Jan 9, 2012
@javisantana
Copy link

@jashkenas you meant this behavior is ok?:

//using current master
test("test previous", 2, function() {
    var model = new Backbone.Model({name : "Tim", age : 10});
    model.set({name : 'Rob'}, {silent : true});
    equal(model.get('name'), 'Rob');
    model.on('change', function() {
      // equal(model.previous('name'), 'Rob'); <- fails 
      equal(model.previous('name'), 'Tim'); <- OK
    });
    model.set({name : 'Test'});
 });

@fernandogmar
Copy link
Author

@javisantana I think so.

But I needed the opposite

test("test previous", 2, function() {
var model = new Backbone.Model({name : "Tim", age : 10});
model.set({name : 'Rob'}, {silent : true});
equal(model.get('name'), 'Rob');
model.on('change', function() {
// equal(model.previous('name'), 'Tim'); <- fails
equal(model.previous('name'), 'Rob'); <- Ok
});
model.set({name : 'Test'});
});

The reason: I need to change values without trigger change events... but at
the same time to keep previous values to unset or recover them. Anyway
thank you for the test :D

On Tue, Jul 17, 2012 at 6:02 PM, javi santana <
reply@reply.github.com

wrote:

@jashkenas you meant this behavior is ok?:

//using current master
test("test previous", 2, function() {
var model = new Backbone.Model({name : "Tim", age : 10});
model.set({name : 'Rob'}, {silent : true});
equal(model.get('name'), 'Rob');
model.on('change', function() {
// equal(model.previous('name'), 'Rob'); <- fails
equal(model.previous('name'), 'Tim'); <- OK
});
model.set({name : 'Test'});
});


Reply to this email directly or view it on GitHub:
#850 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants